Magento script for get collection of multiple product id’s data

As today shared in my magento article, i shared you a query trick by which you will get all sold product data with single query, Now i am going to share you a simple script by which you will get multiple product ids data with single and well optimized code as like collection of array.

Magento collect number of collection of many product from many portions form its database table. Let me explain define you single calling method by which you will get multiple product ids data with single query.

  
     $collection = Mage::getModel('catalog/product')->getCollection()
                  ->setStoreId(Mage::app()->getStore()->getId())
                  ->addAttributeToSelect('*')
                  ->setOrder('entity_id', 'desc')
                   ->addIdFilter(array(id1,id2,id3..idn));
     foreach($collection as $_product)
        {
          echo $_product->getName();//to print product name
        }

As write upper code where addIdFilter filter the data of from collection by which you will get only those product data which you want in your page. you only need to pass those ids and then you will get the results..

Happy coding. 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *