Magento Expert Forum - Improve your Magento experience

Results 1 to 2 of 2

Magento programming work with products and product list functionality

  1. #1
    Moderator shunavi's Avatar
    Join Date
    Mar 2013
    Thanked 25 Times in 16 Posts

    Smile Magento programming work with products and product list functionality

    Product Collection class in magento is Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Col lection. Lets look at the important functions

    Get All Products of a category

    $collection = Mage::getResourceModel('catalog/product_collection')



    Tn this the addCategoryFilter() function, is used to get all products of a particular category. So, if you want to get all products of a certain category use this function.

    Visibility Filter

    PHP Code:
    $collection Mage::getResourceModel('catalog/product_collection');
    The addVisibleFilterToCollection() adds visibility filter to a product collection i.e only products which are visible in frontend. The product which have “Not Visible Individually” selected in admin are removed.

    Status Filter

    PHP Code:
    $collection Mage::getResourceModel('catalog/product_collection');

    This basically filters out products which are “Disabled”. Only “Enabled” products remain in the collection.

    Add Product Price To Collection

    PHP Code:
    $collection Mage::getResourceModel('catalog/product_collection');
    $collection ->addMinimalPrice()


    This adds the product prices, i.e base price, final price etc to the collection. Also, price after tax, if applicable.

    Filter By Ids

    PHP Code:
    $collection Mage::getResourceModel('catalog/product_collection');
    This puts an id filter, only product with ids 1,2,3 remain in the collection. The function parameter is true/false, this means include/exclude products from collection.

    Add Website ID to the collection

    $collection = Mage::getResourceModel('catalog/product_collection');


    This adds website_id of each product to that collection. Only useful when using multiple websites in magento.

    Filter Current Store Products

    PHP Code:
    $collection Mage::getResourceModel('catalog/product_collection');

    Filter Current Website Products

    PHP Code:
    $collection Mage::getResourceModel('catalog/product_collection');

    Get All Products Ids

    PHP Code:
    $collection Mage::getResourceModel('catalog/product_collection');
    This returns an array with only products ids of collection.

    Add SEO Product URL

    PHP Code:
    $collection Mage::getResourceModel('catalog/product_collection');
    This adds SEO friends urls to our product collection.

    Add Category Ids

    PHP Code:
    $collection Mage::getResourceModel('catalog/product_collection');
    This will add category ids to the products.

    Add Tier Pricing

    PHP Code:
    $collection Mage::getResourceModel('catalog/product_collection');

    This added tier pricing data to each product in the collection.While we are on this subject, let look at some important function of the Product Object as well.

    Function in Product Object

    PHP Code:
    This is an important function in magento and used widely. This function return an object of product type class located in folder Mage_Catalog_Model_Product_Type. These classes have function specially related to their product type. For example, functions related to configurable product only are located at Mage_Catalog_Model_Product_Type_Configurable.

    PHP Code:
    This functions returns the id of a product based on its sku. This is usually used, when you want to load a product, but you only have its sku.

    There are many more functions in both class which you should go through and are very useful. These function saves a lot of time, than to write complex sql query.

    View more threads in the same category:

  2. #2
    Junior Member
    Join Date
    Sep 2018
    United Kingdom
    Thanked 4 Times in 4 Posts


    Bundle product is one of the types of products available in Magento. This product type allows a customer to choose from a given range of options to create their own customized version of a product. ... These options are represented by groups of products from which the user can select

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts