Magento get parameters

Get a parameter value: $paramValue = $this->getRequest()->getParam($paramName); Get all parameters and values: $allParams = $this->getRequest()->getParams();

Magento get subcategories

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…

Magento Installation – 404 not found

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…

Magento – TinyMCE Image Uploader / Image incorrect URL

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 =…

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…

Magento – product attribute

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:…

Magento – get product images

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…

Magento – products block

Go to “CMS – Manage Pages” and select the page do you want to display the products from the list of pages. Use next code…