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. 🙂

No Comments

Leave a Reply

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

Google
PC/Internet Tricks

101 Amazing PC / Internet Tricks no one told you before   You Can Search Google Timer In Google For A Timer With Alarm Search This In Google For Direct Mp3 Links intitle:index.of?mp3 Your song name here Use Your Chrome Browser As Notepad Quickly. Just copy the text below to the address Bar. …

develope
Yii2.0 Dynamic Model Creation

As per my previous shared post you have to know what is Yii 2.0 and its awesome features. If you not read these posts please read this and know little bit about Yii2.0 basic(API Web APP) . Today I am sharing you a very new feature of Yii 2.0 which will …

develope
Understand Overriding Magento Controller

Today I’m going to discussing a very cool and best Magento method which is known as overriding. Magento basically base on code pool, where all module/plugin are stored in community and core folder. But when we want to override those modules and all then we are using this awesome process …