To remove a certain block from the Magento cache, use the below code.
1 2 3 |
<reference name="name.of.the.block"> <action method="setCacheLifetime"><s>null</s></action> </reference> |
To remove a certain block from the Magento cache, use the below code.
1 2 3 |
<reference name="name.of.the.block"> <action method="setCacheLifetime"><s>null</s></action> </reference> |
The following MySQL query returns the status of every product in the Magento database.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
SELECT cpe.sku, q.product_status FROM catalog_product_entity cpe JOIN (SELECT entity_id AS product_id, value AS product_status FROM catalog_product_entity_int WHERE entity_type_id = (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = 'catalog_product') AND attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'status' AND entity_type_id = (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = 'catalog_product'))) q ON cpe.entity_id = q.product_id; |
Status 1: active Status 2: not active
Open the category in the admin area (backend) and add the following xml to the layout update section.
1 2 3 |
<reference name="product_list"> <action method="setColumnCount"><count>4</count></action> </reference> |
Searching for something while being on a https secured page opens a warning dialog. Thats annoying for the visitor of your page. To fix that problem, open a suitable module or create a new one and add the following xml…
Using the code below you can call a stored procedure directly from Magento.
1 2 3 4 |
$resource = Mage::getSingleton('core/resource'); $readConnection = $resource->getConnection('core_read'); $query = 'CALL stored_procedure()'; $results = $readConnection->exec($query); |
Use the code below to redirect to any page from a Magento template (phtml) file. In this case, it is a redirect to the home page.
1 |
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl()); |
Add the following code to your themes catalog\product\list.phtml file. It will change the column count to 2.
1 |
$this->setColumnCount(2); |
The below code shows how to echo the HTML of a block with the id ‘my_block’.
1 |
echo $this->getLayout()->createBlock('cms/block')->setBlockId('my_block')->toHtml(); |
One step towards making your shop more secure is to change the default admin route from http://www.your-shop.com/admin to something more secure and less guessable. The route must be changed in app/etc/local.xml.
1 2 3 4 5 6 7 8 9 |
<admin> <routers> <adminhtml> <args> <frontName>your-new-backend-route</frontName> </args> </adminhtml> </routers> </admin> |
After adding that to your app/etc/local.xml file, clear…
The following code returns all products from within a certain category in a collection.
1 2 3 |
// category id = 5 // addAttributeToSelect is optional $products = Mage::getModel('catalog/category')->load(5)->getProductCollection()->addAttributeToSelect('*'); |