1

I need to get all product descriptions(and maybe some other attributes). For example, for product with id 2:

  • Store id 1: "First store description"
  • Store id 2: "Second store description"
  • Store id 3: "Third store description"

Is there some different way than getting all store id's and then in a loop for each one store id load product with id 2 and getting it's own description?

2

If I understood you don't want to loop through all the store ids and you just want to loop through the ones that the product Id 2 has the stores:

$item = Mage::getModel('catalog/product')->load(2);
$storeIds = $item->getStoreIds();

then you loop through the stores of product id 2 and you get descriptions:

    foreach($storeIds as $storeId)
   Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'attribute_code', $storeId);
| improve this answer | |
0

To load a product without looping like the below example, you can set the store id, like so:

$storeId = 2; // or whatever store you want

$product = Mage::getModel('catalog/product')
            ->setStoreId($storeId)
            ->load($_product->getId());

Then grab the info as usual ..

$product->getName(); 

etc ..

.. the loop method is:

foreach (Mage::app()->getWebsites() as $website) {

    foreach ($website->getGroups() as $group) {

        $stores = $group->getStores();

        foreach ($stores as $store) {

            // store id
            $storeId = $store->getId();

            // do your other stuff here ...

        }
    }
}
| improve this answer | |
  • Thx, but it is not the way i'm looking for :) – Serge Apr 10 '15 at 8:52
  • I've edited my answer =) – tecjam Apr 10 '15 at 9:02
  • Yep, but then I have to load product for each element from store id's array(1,2,3, 4..). That is the same as below, with difference that we know desire store ids. I'm interesting for some simply and elegance solution or confirmation that this no way out than loading product for each store id. – Serge Apr 10 '15 at 9:06
  • Ah ok, so you want something like this to work: $product->setStoreId($storeId)->getName(); to grab the info without loading the product for the store view first? I don't think this works, but I may be wrong. – tecjam Apr 10 '15 at 9:08
  • Yes, that could be great, but it returns only default name, unfortunately.. – Serge Apr 10 '15 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.