search
top

Get all product attributes in Magento

Hello All, I am writing here a simple but important code snippet for getting all the existing product attributes $attributes = Mage::getSingleton('catalog/config')->getProductAttributes(); echo '<pre>'; print_r($attributes); exit;
read more

Product Quantities Ordered in Magento

I am explaining here the way to display the total quantities ordered in the Product view page. I have used Magento version 1.7.0.2 1) Block file Create a file app/code/local/Mage/Catalog/Block/Product/View/Quantity.php (note the codepool is ‘local’ ) Copy this code in the file and save the file. class Mage_Catalog_Block_Product_View_Quantity extends Mage_Catalog_Block_Product_View_Abstract { ...
read more

Limit results collection in Magento

Many times need arises to limit collection for say pagination or for any customization. I am listing here an example which shows how to limit the collection. I have used the Product Model below. <?php $limit = 5; $starting_from = 2; $product_collection = Mage::getModel('catalog/product')->getCollection()->setOrder('name', 'asc'); //getting the product collection, results are ordered by...
read more

Optgroup in Magento

For a module I was working on in one of my project, I needed to display a select box, with optgroup, Magento has inbuilt function for this. Kindly go through this post Select Box in Magento of mine for understanding how to generate select box before reading forward. For option group you need to pass the ‘value’ also as an array. Suppose your Category name is ‘Furniture’ and...
read more

Category and Product SOAP API in Magento

In one of my post I explained the basics of SOAP API, please refer Magento SOAP API before proceeding further I am listing here the methods to create Categories and Products using SOAP API 1) Category a) Category Creation <?php $category_name = 'Test Category'; //create new category //start $category = array( 2, array('name'=>$category_name, 'display_mode' => PRODUCTS_AND_PAGE, 'is_anchor'...
read more

Root Category in Magento

In Magento, products are assigned to Website, though we can disable the product in independent store, but this is very lengthy procedure as you need to edit each and every products. So I came up with the solution to restrict the display of categories and products, though if you assign different Root Catalog to different store, Magento will display the categories as per the stores but not products as...
read more

Empty Cart in Magento

In one of my project, I needed to explicity delete the items from cart after order placed. You can also use this script for making a functionlity for giving an option for empting the cart at once from cart page. Here is the script for the same. Place it in function ‘successAction’ in app\code\local\Mage\Checkout\controllers\OnepageController.php (copy this file from app\code\core\Mage\Checkout\controllers\OnepageController.php) /** ...
read more

Product Quantity in Magento

For one of my project I needed to display the total quantities ordered in Products lifetime in product view page. Here is the code $product_id = 1; // the id of the product for which the quantities is required $current_storeid = Mage::app()->getStore()->getId();//get current store id, used for filtering the collection $productCollection = Mage::getResourceModel('reports/product_collection') ->addOrderedQty()...
read more

Select Box in Magento

Hello All, I am listing here a useful topic related to Magento. Below is the description to generate a select box using inbuilt functions of Magento. Lets take an example of displaying a select box containing all the catalog products. I am using the existing core files for better understanding, you are recommended make new module or override existing files Lets use helper file of Catalog, app/code/core/Mage/Catalog/Helper/Data.php Paste...
read more

Product Collection in Magento

Hello All, I am writing here the script to get product collection of the store. <?php $collection = Mage::getResourceModel('catalog/product_collection'); $collection->addAttributeToFilter('status',1); //only enabled product $collection->addAttributeToFilter('visibility',array("neq"=>1)); //except not visible individually $collection->addAttributeToSelect(array('name','url','small_image'));...
read more

« Previous Entries

top