Magento – cms tags
Display a magento block in CMS Page: {{block id=’block_id’}} {{block type=’module/package_classname’ template=’path/to/template.phtml’}} Escapes all HTML tags in the value of the var attribute, except for…
Display a magento block in CMS Page: {{block id=’block_id’}} {{block type=’module/package_classname’ template=’path/to/template.phtml’}} Escapes all HTML tags in the value of the var attribute, except for…
Get attribute collection: $attribute = $_product->getResource()->getAttribute(‘attribute_name’); Get attribute type: $attribute->getAttributeType(); Get attribute Label: $attribute->getFrontendLabel(); Get attribute default value: $attribute->getDefaultValue(); Check if the attribute is visible:…
This code can be used to get all images for product: $_product = Mage::getModel(‘catalog/product’); $_product->load($product_id); // Get image gallery $_gallery = $_product->getMediaGalleryImages(); // Go through…
Go to “CMS – Manage Pages” and select the page do you want to display the products from the list of pages. Use next code…
Print an array elements in smarty template: {$my_array|print_r}
To run a script in command line: php test.php or php -f test.php To run a script in command line with parameters: php test.php param1…
To view php script execution time insert next code into your script. Insert next code at the top of the page: <?php $mtime = microtime();…
Use this code to disable right click on html pages: <body oncontextmenu=”return false;”>
This is a method to verify if a customer is logged in or not: if(Mage::getSingleton(‘customer/session’)->isLoggedIn()) { // Code to execute }
Next code is a method to get all product from magento database: $products = Mage::getModel(‘catalog/product’)->getCollection(); $products->addAttributeToFilter(‘status’, 1);//enabled $products->addAttributeToFilter(‘visibility’, 4); //catalog, search $products->addAttributeToFilter(‘type_id’, ‘simple’); //catalog, search…