1

I need help with getting some values out of my code.So I have my configurable product and it is based on a global attribute "size", it has its own associated products which are the same product in different sizes. I need to somehow call a model or something that will give me the associated products and their label for the attribute "size" for example "xxl".
What I did so far was to get all child products. But the this size value is an Int, and there is no size label variable.

Another thing I'd like to add if it helps: the size variable from child products and the value_index from "size" options are the same.

UPDATE

This is the code and need to insert the label in it and to get it displayed in a foreach as a li element

$product1= Mage::getModel('catalog/product')->load($_product->product_id); 
$childProducts = Mage::getModel('catalog/product_type_configurable')
                         ->getUsedProducts(null,$product); 

foreach($childProducts as $child) {

    print_r($child->getId()); 
    print_r($child->getsize()); 

}
  • I'm pretty sure I gave you the answer just below. – Julien Lachal Jul 17 '14 at 13:54
3
    Mage::getModel('catalog/product')->getResource()->getAttribute("size")->getSource()->getOptionText("your_id");
  • glat it helped. – Julien Lachal Jul 17 '14 at 14:32
  • @JulienLachal How to do this in M2? – Joey Apr 18 '18 at 6:06
  • @Joey I don't know, haven't touched Magento in a while, but a quick search will yield results for sure – Julien Lachal Apr 18 '18 at 7:00
  • @JulienLachal I tried. couldn't find what I needed. thanks anyways – Joey Apr 18 '18 at 13:18

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.