Frage

Angenommen, ich habe ein Attribut, das eine Sammlung von Optionen ist (Dropdown/Multiselect).

Ich kann den Attributwert für ein bestimmtes Produkt abrufen:

$store_id = [something];
$productId = [something];
// this is a select/multiselect
$attribute_code = [something]; 

$option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code, $store_id );
$option_label = ???

Jetzt habe ich das Attributoption_ID erhalten, was ein numerischer Wert ist ...

... Was ist der beste Weg, um das Frontend -Attribut -Etikett für meinen Attributwert zu laden? (ohne das vollständige Produkt zu laden)

Lösung Danke Marius:

// Not loading the product - just creating a simple instance
$product = Mage::getModel('catalog/product')
->setStoreId($store_id)
->setData($attribute_code,$option_id); 
$option_label = $product->getAttributeText($attribute_code);
War es hilfreich?

Lösung

Zusätzlich zu Ihrem Code geben Sie Folgendes ein:

$product = Mage::getModel('catalog/product')
                ->setStoreId($store_id)
                ->setBrand($brand_value); // not loading the product - just creating a simple instance
$brandLabel = $product->getAttributeText('brand');

Andere Tipps

$attribute = Mage::getModel('catalog/resource_eav_attribute')
            ->loadByCode(Mage_Catalog_Model_Product::ENTITY, 'manufacturer');
$label     = $attribute->getFrontendLabel();
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top