MatheusJardimB
MatheusJardimB

Reputation: 3677

Magento - Get attribute value per website

I've created (manually via Admin Panel) an attribute called att_by_website which is scoped as 'Website' and I'm want to get its several values.

How can I do this? I'm able to set different values via Admin Panel, but at this time I'm only able to get the default value.

When I execute $this->getProduct()->getData('att_by_website') it returns only the default value (where $this->getProduct() returns an instance of Mage_Catalog_Model_Product).

Thanks!

Upvotes: 2

Views: 7388

Answers (2)

MatheusJardimB
MatheusJardimB

Reputation: 3677

It may not be the best approach, but solved the problem:

$value = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productID, 'att_by_website', $storeId);

Upvotes: 5

Kenny
Kenny

Reputation: 5410

Try this:

foreach (Mage::app()->getWebsites() as $website) {
    $websiteId = $website->getWebsiteId();
    $storeId = $website->getDefaultGroup()->getDefaultStoreId();
    Mage::app()->setCurrentStore($storeId);

    echo $this->getProduct()->getData('att_by_website');
}

Upvotes: 1

Related Questions