Currently browsing

September 3, 2018

Magento: Upgrading mysql setup of a module

Suppose, you have a module called MyModule. Its version is 0.1.0. Now, you want to do some database changes for the module. You have the mysql setup file (mysql install file) mysql4-install-0.1.0.php in MyModule/sql/mymodule_setup folder of your module. You don’t need to make direct changes to database. You can upgrade your module to make …

Magento: Get category name and url from product

$product->getCategoryIds() gives array of category ids which the product is associated to. We can loop through this array and load each category to get the category name and url. <?php /** * get categories from a product */ $categoryIds = $product->getCategoryIds(); /** * looping through the array of category ids …

Magento: Get store information

Below is the code to get Magento store id, store code, store name, etc. Get store data Mage::app()->getStore(); Store Id Mage::app()->getStore()->getStoreId(); Store code Mage::app()->getStore()->getCode(); Website Id Mage::app()->getStore()->getWebsiteId(); Store Name Mage::app()->getStore()->getName(); Is Active Mage::app()->getStore()->getIsActive(); Store Home Url Mage::app()->getStore()->getHomeUrl(); Looking for improvement for your Magento Store? Facebook Connector Extension Product related article …

Magento: Get height and width of Image

Image functions are defined in catalog/image helper. getOriginalWidth gives width of image. getOriginalHeigh gives height of image. It is not getOriginalHeight(). Spelling mistake from Magento : getOriginalSizeArray gives the height and width of an image in array. $_product = $this->getProduct(); $imageWidth = $this->helper(‘catalog/image’)->init($_product, ‘image’)->getOriginalWidth(); if($imageWidth > 600) { $lightboxImage = …