Magento – save and get data from cache
Just a method to save and get data from magento cache $mydataforcache = “My data for cache”; $cache_name = “maycachename”; $CACHEDATA = MAGE::app()->loadCache($cache_name); if (isset($CACHEDATA)…
PHP development
Just a method to save and get data from magento cache $mydataforcache = “My data for cache”; $cache_name = “maycachename”; $CACHEDATA = MAGE::app()->loadCache($cache_name); if (isset($CACHEDATA)…
Specify the DocType $this->doctype(‘XHTML1_STRICT’); XHTML1_STRICT – XHTML 1.0 Strict XHTML1_TRANSITIONAL – XHTML 1.0 Transitional HTML4_STRICT – HTML 4.01 Strict HTML4_Loose – HTML 4.01 Loose HTML5…
Script to import newsletter subscribers
Get customer group Id // Check if costomer is logged in if(Mage::getSingleton(‘customer/session’)->isLoggedIn()) { // Get group Id $groupId = Mage::getSingleton(‘customer/session’)->getCustomerGroupId(); } Get group name: $group…
Magento get front controller name: Mage::app()->getFrontController()->getRequest()->getRouteName()
Get a parameter value: $paramValue = $this->getRequest()->getParam($paramName); Get all parameters and values: $allParams = $this->getRequest()->getParams();
Get subcategories of a main category: $_cat = Mage::getModel(‘catalog/category’)->load($cat_id); $_subcats = $_cat->getChildrenCategories(); foreach ($_subcats as $subcat) { echo “<h1>” . $subcat->getName() . “<h1>”; } Get…
Hack to solve the “404 Not Found error” after magento installation: Replace in the original index.php: Mage::run(”); with Mage::run(‘default’); Instead of ‘default’ can be used…
Small hack in file: app/code/core/Mage/Cms/Helper/Wysiwyg/Images.php to correct image url from something like: <img src=”http://www.mysite.com//index.php/admin/cms_wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ii9jbGFzc2lmaWVkVUwuanBnIn19/key/f90eef374eaee0f5b76fc9783680c059/” /> into the correct image url. public function getImageHtmlDeclaration($filename, $asIs =…
Add contact form to CMS Pages: {{block type=”core/template” name=”contactForm” form_action=”/contacts/index/post” template=”contacts/form.phtml”}}