This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Mage::getModel('my_model') | |
->getCollection() | |
->addAttributeToFilter('my_column', array('gt' => Zend_Db_Expr(MY_EXPRESSION))) | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$canonicalUrl = Mage::getBaseUrl(); // your logic... | |
$this->getLayout() | |
->getBlock('head') | |
->addLinkRel('canonical', $canonicalUrl); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* In some Mage_Adminhtml_Block_Catalog_Form class... | |
*/ | |
protected function _prepareForm() | |
{ | |
$formDataObject = new Varien_Object() // Your logic to get original data for your form | |
$form = new Varien_Data_Form(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<php | |
/** | |
* Parse variables string into array of variables | |
* | |
* @param string $variablesString | |
* @return array | |
*/ | |
protected function _parseVariablesString($variablesString) | |
{ | |
$variables = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 1) Make sure to display a correct date or datetime input field in admin forms | |
* | |
* Code below is in a _prepareForm() method of an admin form | |
*/ | |
$dateOutputFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); | |
$fieldset->addField('my_date_field', 'date', array( | |
'name' => 'my_date_field', | |
'label' => $this->__('My Date Field'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Update config node /config/global/sales/order/states like this: --> | |
<config> | |
<global> | |
<sales> | |
<order> | |
<states> | |
<[state_code]> | |
<!-- | |
Available state_code are: | |
. new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code must in a block class, child of Mage_Core_Block_Abstract | |
// Retrieve value of 'alt-template' attribute from layout for current block | |
$blockElement = $this->getLayout()->getXpath("*/block[@name='" . $this->getNameInLayout() . "']"); | |
if($blockElement) { | |
/* @var $blockElement Mage_Core_Model_Layout_Element */ | |
$blockElement = end($blockElement); | |
$altTemplate = $blockElement->getAttribute('alt-template'); | |
if(!is_null($altTemplate)) { | |
$this->setTemplate($altTemplate); // Or your logic... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Mage::getSingleton('core/session')->setSkipSessionIdFlag(true); | |
// line below may also be needed | |
Mage::app()->setUseSessionInUrl(false); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Just create as many shopping cart price rules that are elligible for free shipping | |
and this block class will use the most appropriate one to define: | |
- minimum amount to get freeshipping | |
- remaining amount to purchase to get freeshipping. | |
If no rule is elligible, the block falls back to a CMS block. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$installer = $this->startSetup(); | |
$installer->getConnection() | |
->addColumn( | |
$installer->getTable('module/table_alias'), | |
'sql_column_name', | |
array( | |
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, // Or any other type from Varien_Db_Ddl_Table | |
'nullable' => true, // Or false... |