0

I have created a multiselect catalogue product attribute labelled dangerous (attribute ID: 1202) which should work exactly like an existing custom attribute sport (attribute ID: 1200).

The attribute is set up with the following options:

  • Scope: Global
  • Use In Layered Navigation: Filterable (with results)
  • Used in Product Listing: Yes

My new dangerous attribute shows up properly in the product edit form in a multiselect dropdown. When I select options and save the product I can see the database getting updated.

The only problem I have is that I can't seem to get the dangerous attribute value via the getData() method.

Mage::getModel('catalog/product')->load(494643)->getData() returns

Array (
    ...
    [supplier_warehouse] => United Kingdom
    [sport] => 4000
    [dangerous] =>
    [meta_keyword] => Nike Livestrong, Summer Cap (Black), Black, Headwear 
    ...
)

and both Mage::getModel('catalog/product')->load(494643)->getDangerous() and Mage::getModel('catalog/product')->load(494643)->getData('dangerous') return null.

On the other hand, this query:

SELECT
    cpe.entity_id AS product_id,
    cpev_sport.value AS sport,
    cpev_dangerous.value AS dangerous
FROM catalog_product_entity AS cpe

LEFT JOIN catalog_product_entity_varchar AS cpev_sport
ON cpev_sport.attribute_id = 1202
AND cpe.entity_id = cpev_sport.entity_id

LEFT JOIN catalog_product_entity_varchar AS cpev_dangerous
ON cpev_dangerous.attribute_id = 1200
AND cpe.entity_id = cpev_dangerous.entity_id

WHERE cpe.entity_id = 494643

returns

+------------+-------+-----------+
| product_id | sport | dangerous |
+------------+-------+-----------+
|     494643 | 4000  | 4087      |
+------------+-------+-----------+
1 row in set (0.00 sec)

Am I missing something obvious? Please note that I tried reindexing and clearing all types of cache, in vain so far.

EDIT: Additional info
I am using multi-store indeed but these attributes have a global scope (store ID: 0).
I have tried reindexing and clearing cache.

  • Are re indexing from admin??? – Amit Bera Aug 4 '14 at 12:56
  • are you used multi store – Amit Bera Aug 4 '14 at 12:56
  • are you using flat tables for products? – Julien Lachal Aug 20 '14 at 14:57
  • and how did you add your products, manually or via import? – Julien Lachal Aug 20 '14 at 14:58
  • Yes, I do use flat tables for products. However, in the edit form, I believe that Mage::getModel('catalog/product')->load(494643) doesn't read it from that table since it isn't a collection. Unless I'm wrong? Products were all imported via Magmi, but I'm unsure whether that would make any difference. – Alexandre Leprêtre Aug 21 '14 at 10:31
1

Try using $product->getDangerous() after flushing cache since often collections are cached.

  • I flushed all cache types I could think of but it didn't help, when I update the sport attribute value, it's updated immediately though. The product is loaded directly from the model and not from a collection. I didn't get more successful with $product->getDangerous() which returns null – Alexandre Leprêtre Aug 4 '14 at 12:37

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.