Posts

Showing posts from July, 2014

Get Attribute Value on Product Page Based on the Attribute Code

echo $_product->getAttributeText('your_attribute_code');

How to Get Attribute Name and Value?

Attribute in Magento is like a property. All Products, Categories, Orders, Customers, etc. have attributes. For example, the attribute of a product is its name, sku, description, image, etc. This article will show you how to get attribute name and value for any product. Get attribute’s name, value, type, and other parameters The attribute code in the case below is my_attribute . /**   * get attribute collection   */ $attribute = $_product ->getResource()->getAttribute( 'my_attribute' ); /**   * get attribute type   */ $attribute ->getAttributeType(); /**   * get attribute Label   */ $attribute ->getFrontendLabel(); /**   * get attribute default value   */ $attribute ->getDefaultValue(); /**   * check if the attribute is visible   */ $attribute ->getIsVisible(); /**   * check if the attribute is req...

How to get parent category Id in Magento

To get Parent Category Id you must know the current category Id, for that you need to write <?php $_cat = new Mage_Catalog_Block_Navigation(); $curent_cat = $_cat->getCurrentCategory(); $curent_cat_id = $curent_cat->getId();?> Now you can get Parent Category Id. write the code given below to get the Id <?php $parentId=Mage::getModel('catalog/category')->load($curent_cat_id)->getParentId(); echo $parentId; // $parentId will print your current category's parent Id ?>

Fix Category Url Filter in Magento

Arguably one of the best features of Magento from a usability perspective is its powerful layered navigation system, which allows the customer to filter down the products presented to them from a category, enabling them to find the best products specific to their needs. A major downside to this filtering, is in the URLs generated. Magento will append a query string containing filter parameters to the current category URL, resulting in rather unhelpful (not to mention non-SEO friendly!) URLs such as www.yoursite.com/electronics.html?manufacturer=120 . Under normal circumstances, and for attributes such as “price” or “manufacturer”, this isn’t such a major issue. However, when it comes to the category filter it can present rather a large problem. To access, for example, the “Camera” category in the sample Magento installation, you could visit either of: www.yoursite.com/electronics/cameras.html www.yoursite.com/electronics.html?cat=12 Obviously the latter here is an i...

Magento Category Tree is Not Showing In Product Edit (Backend)

Today i got very strange problem in my client’s Magento set up… When i have open products in edit mode in Magento 1.5 Admin then categories tree for product does not expand to show product sub-categories… Only Root categories were visible… I couldn’t find proper solution for this problem… But i did patch which worked perfectly for me. Hope this will help to someone else too… Solution: There is some change in Categories.php file of magento 1.4.2 and 1.5.x So,i have backed up old Categories.php in: app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Categories.php i have changed 1.5 store code by the 1.4.2 code and yeahh; it works fine. Categories are auto expanded Change the last fonction by below code in file which you are going to replace. public function getSelectedCategoriesPathIds($rootId = false) { $ids = array(); $collection = Mage::getModel('catalog/category')->getCollection() ->addFieldToFilter('entity_id',...

Magmi Single and Multiple Category Importer

Image
Magmi On the fly Category Creator Magmi can create or update categories while it is importing products This document refers to On the fly category creator Version 0.2.3 Categories column To assign your products to categories, include a column called "categories" in your CSV file. If a category branch does not exist, it will be created on the fly during the import process and your products will be assigned to it sku,name,categories "100","My Products/Sample Products/Sample Category" "101","My Products/Other Products" 1 2 3 sku , name , categories " 100 " , " My Products / Sample Products / Sample Category " " 101 " , " My Products / Other Products " Each branch level of the category tree is separated with a forward slash (/). In the example shown above, the two products will be put into their own categories and the following tree ...

To add Product Count in Cart

echo Mage :: helper ( 'checkout/cart' )-> getItemsCount ();

How to Remove Parent Category Path From Sub Category in Magento URL?

Step 1: Edit "/app/code/core/Mage/Catalog/Model/Url.php" Around line 805 comment the below lines: view plain print ? //if (null === $parentPath) {    //    $parentPath = $this->getResource()->getCategoryParentPath($category);    //}    //elseif ($parentPath == '/') {         $parentPath  =  '' ;   //}    Step 2: Now re-index Catalog URL Rewrites in Index Management. That's it you are done.