This file contains hidden or 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 | |
/** @var Mage_Eav_Model_Entity_Setup $installer */ | |
$installer = $this; | |
$installer->startSetup(); | |
$this->addAttribute( | |
'catalog_category', | |
'my_custom_attribute', | |
array( | |
'group' => 'General Information', |
This file contains hidden or 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
// This snippet from line 267 of class Mage_Adminhtml_Model_Sales_Order_Create of Magento CE 1.8.x or EE 1.13.x | |
public function initFromOrder(Mage_Sales_Model_Order $order) | |
{ | |
// ... | |
$this->getQuote()->getPayment()->addData($order->getPayment()->getData()); // line 329 | |
// ... | |
$this->getQuote()->save(); | |
return $this; | |
} |
This file contains hidden or 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 | |
// Prevent this script to be called via HTTP | |
if (isset($_SERVER['REQUEST_METHOD'])) | |
{ | |
die('Permission denied.'); | |
} | |
// Avoid any time limit | |
set_time_limit(0); |
This file contains hidden or 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 | |
// Prevent this script to be called via HTTP | |
if (isset($_SERVER['REQUEST_METHOD'])) | |
{ | |
die('Permission denied.'); | |
} | |
// Avoid any time limit | |
set_time_limit(0); |
This file contains hidden or 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
protected function _beforeSave() | |
{ | |
$this->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate()); | |
if ($this->isObjectNew() && null === $this->getCreatedAt()) { | |
$this->setCreatedAt(Mage::getSingleton('core/date')->gmtDate()); | |
} | |
return parent::_beforeSave(); | |
} |
This file contains hidden or 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
$originalCollection = Mage::getModel('catalog/product') | |
->getCollection(); | |
$newCollection = Mage::getModel('catalog/product') | |
->getCollection(); | |
$selectParts = array( | |
Varien_Db_Select::DISTINCT, | |
Varien_Db_Select::COLUMNS, | |
Varien_Db_Select::UNION, |
This file contains hidden or 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 | |
require_once 'abstract.php'; | |
class Mage_Shell_CheckImages extends Mage_Shell_Abstract | |
{ | |
const CATALOG_PRODUCT = '/catalog/product'; | |
const CACHE = '/cache/'; | |
protected function _glob_recursive($pattern, $flags = 0) |
This file contains hidden or 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
public function log() | |
{ | |
$args = func_get_args(); | |
$formattedMsg = call_user_func_array('sprintf', $args); | |
Mage::log($formattedMsg, null, 'vendor_module.log', Mage::getStoreConfig('path/to/config')); | |
} |
This file contains hidden or 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
$product = new Varien_Object(); | |
$product->setId(363004); | |
$attribute = Mage::getSingleton('catalog/product')->getResource()->getAttribute('media_gallery'); | |
$media = Mage::getResourceSingleton('catalog/product_attribute_backend_media'); | |
$gallery = $media->loadGallery($product, new Varien_Object(array('attribute' => $attribute))); |
This file contains hidden or 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 | |
class Myvendor_Mymodule_Helper_Data extends Mage_Core_Helper_Data | |
{ | |
/** | |
* Check whether current Magento version supports Transactions | |
*/ | |
public function isTransactionSupported() | |
{ | |
return version_compare(Mage::getVersion(), '1.4.0.1', '>'); | |
} |
OlderNewer