Skip to content

Instantly share code, notes, and snippets.

<script>
my_variable = '<?php echo $this->getBigTemplate();?>';
</script>
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference="head">
<action method="addCss"><stylesheet>css/YOURSTYLESHEET.css</stylesheet></action>
</reference>
</default>
</layout>
<?xml version="1.0"?>
<config>
<modules>
<YOUR_MODULE>
<version>0.1.0</version>
</YOUR_MODULE>
</modules>
<frontend>
<layout>
<updates>
<?php
$i++;
$_class = '';
if ($i % 4 == 0) $_class .= ' last-4-col';
if (($i - 1) % 4 == 0) $_class .= ' first-4-col';
if ($i % 3 == 0) $_class .= ' last-3-col';
if (($i - 1) % 3 == 0) $_class .= ' first-3-col';
$_class .= ($i % 2 == 0) ? ' even' : ' odd';
?>
<?php
class Ip_Category_Model_Image
{
public function getResizedImage($image, $width, $height = null, $quality = 100)
{
if(!$image){return false;}
$imageUrl = Mage::getBaseDir('media').DS."catalog".DS."category".DS.$image;
if(!is_file($imageUrl)){return false;}
$imageResized = Mage::getBaseDir('media').DS."catalog".DS."category".DS."cache".DS."cat_resized".DS.$image;
<?php
$installer = $this;
$installer->startSetup();
$installer->getConnection()
->addColumn($installer->getTable('sales/quote'), 'surcharge', 'decimal(12,4)');
$installer->getConnection()
->addColumn($installer->getTable('sales/order'), 'surcharge', 'decimal(12,4)');
$installer->endSetup();
@ryaan-anthony
ryaan-anthony / gist:8289750
Created January 6, 2014 21:00
create the following procedure, then to call it: type "call sort_categories;" in mysql.
delimiter ;;
drop procedure if exists sort_categories;;
create procedure sort_categories()
begin
DECLARE cur_id BIGINT UNSIGNED;
DECLARE cur_eof INT DEFAULT FALSE;
DECLARE cur CURSOR FOR
SELECT entity_id
FROM catalog_category_entity_varchar
WHERE attribute_id = (
@ryaan-anthony
ryaan-anthony / Block Class
Created December 4, 2013 20:52
Hide all payment methods if none needed.
<?php
class Your_Custom_Block_Rewrite extends Mage_Checkout_Block_Onepage_Payment_Methods
{
protected function _canUseMethod($method)
{
$total = $this->getQuote()->getShippingAddress()->getBaseGrandTotal();
if((float)$total > 0){return parent::_canUseMethod($method);}
server {
listen 80;
#listen 443 ssl;
#ssl_certificate tls/magento_local.pem;
#ssl_certificate_key tls/magento_local.key;
#ssl_session_timeout 7m;
## Specify your SSL options here
#ssl_protocols SSLv2 SSLv3 TLSv1;
#ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
$options = Mage::getModel('sales/quote_item_option')
->setItemId($item->getId())
->getCollection()
->getOptionsByItem($item);
foreach($options as $option){
if($option->getCode() == "info_buyRequest" && $buy_request = $option->getValue()){
$buy_request = unserialize($buy_request);
if(isset($buy_request['custom_options']['cake'])){
//cake is found in the custom_options of a buyRequest