Setting And Getting Cookies
To set cookies:
Mage::getModel('core/cookie')->set('cookie_name', 'cookie_value', 0); # session cookie
Mage::getModel('core/cookie')->set('cookie_name', 'cookie_value', 60); #lasts 60 seconds
To get cookies:
Mage::getModel('core/cookie')->get('made_productalerts_stock');
Related cards:
Getting A Products URL
Potentially confusing due to the 3 methods you could use, all of which are in Mage_Catalog_Model_Product
:
public function getUrlPath($category=null)
public function getUrlInStore($params = array())
public function getProductUrl($use...
Stock Availability on Credit Note, Cancellation and Payment Deny
In summary - making a credit memo can increase the stock quantity but will never set the "Stock Availability" of the product to "In Stock", whereas a config option can control whether an order cancellation sets "In Stock" automatically. Denying a ...
Setting Data Per-Store On Entites
Certain entities (Products and Categories, for example) have the concept of a
store scope, whereby you can set the default value for all stores, or you can
set a value on a per-store basis.
You could do it this way, and this is probably how most ...
Import and URL Keys
Don't bother setting the url key, as this can be a tedious task in Excel, just simply import without one and reindex.
Layout Loading and Misc Notes
Layout XML files are loaded here via this stack - here we are loading the layout update for the rwd/default design package, for the CMS home page. I've put a dashed line on the demarcation between layout code and other code:
Mage_Core_Model_A...
Import Resetting visibility and stock attributes
If you are updating an existing product you need to include the stock and visibility attributes, otherwise the stock for the product will get set to 0 and out of stock, and the visibility will be reset to Catalog, Search.
![](http://mikewhitby.co...
Cache Clearing And General Information
Clean everything (use either):
Mage::app()->getCacheInstance()->flush();
Mage::app()->getCache()->clean();
Clean specific types:
Mage::app()->getCacheInstance()->cleanType('config');
Mage::app()->getCacheInstance()->cleanType('l...
startSetup() and endSetup()
Ever wondered what they do? Basically they disable and then enable foreign key checks, and set the SQL mode to NO_AUTO_VALUE_ON_ZERO, then back to the old SQL mode. Below is the code taken from Varien_Db_Adapter_Pdo_Mysql
:
/**
* Run ad...
Boilerplate Resource Model Class (CE 1.6 / EE 1.11 And After)
/**
* Yourcompany.com
*
* PHP Version 5
*
* @category Namespace
* @package Namespace_Module
* @author Your Name <your.name@yourcompany.com>
* @copyright 2012 yourcompany.com
* @license http:...
Messages and Global Messages Blocks
Both use the same block, as we can see in page.xml
:
<block type="core/messages" name="global_messages" as="global_messages"/>
<block type="core/messages" name="messages" as="messages"/>
When you add a message, you add it to the session...