I have a product attribute for delivery time akeneo_delivery_time
, that's filled from a PIM (akeneo) by import. This is of type "Dropdown" with scope of "Store View" (We have two storeViews, with locales of de_DE and fr_FR). The options contain translations of the delivery time text for every locale.
I wanted to keep the delivery_time
attribute that comes with magento (mage_setup), which is of type "text", in order to not break compatibility which 3rd party extensions.
My idea was to write an indexer that transferes the attribute frontend-values of the "Dropdown" to the text attribute "delivery_time". There is no problem with that, it works fine.
But i cannot get the locale specific value. getAttributeText
gives my the correct option for the storeViews, but not in the locale of that storeView. I get the option text in "de", never in "fr".
$stores = Mage::app()->getStores();
foreach ($stores as $store) {
Mage::app()->setCurrentStore($store);
$productCollection = Mage::getModel('catalog/product')->getCollection();
$resource = Mage::getResourceSingleton('catalog/product');
foreach ($productCollection as $product) {
$akeneoDeliveryTime = $product->getAttributeText('akeneo_delivery_time');
$product->setData('delivery_time', $akeneoDeliveryTime);
$resource->saveAttribute($product, 'delivery_time');
}
}
What am i doing wrong here? Do I need to set locale somewhere?
I have seen in Mage_Catalog_Block_Product_View_Attributes, it works like this:
public function getAdditionalData(array $excludeAttr = array())
{
$data = array();
$product = $this->getProduct();
$attributes = $product->getAttributes();
foreach ($attributes as $attribute) {
if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
$value = $attribute->getFrontend()->getValue($product);
But here "$product" contains translates option values from the start.