0

I am looking to update the short description when the user selects different items in the dropdown of a configurable product.

What I am struggling to wrap my head around is how I would get the short description.

So on the frontend I have the dropdown which has the attributes for example IDs 257-259, I then have products assigned to these attributes, which are then assigned to the configurable product.

From this ID and the Configurable product ID how would I go about getting the simple product short description and assign it in an array to the attribute ID?

I can get a list of the simple product IDs with the following:

$ids = Mage::getResourceSingleton('catalog/product_type_configurable')->getChildrenIds($_product->getId());

I am already extending getJsonConfig in order to add some price variations to my page, I'd like to add the short description into the JS spConfig - I can do the following to spConfig:

'shortDescription' => $currentProduct->getShortDescription(),

But this is the parent product and not the simple one. I am looping through the options and I add the attribute ID and label to my array, but I don't know how to get X product with Y attribute that is from Z configurable.

  • You need to use ajax call when customer selects any options and through that option you will get the child product id, by that product id you will get short description then update the short description section after the ajax call. – Sukumar Gorai Jul 4 '18 at 13:33
  • I have an extended getJsonConfig which I would prefer to use and have the information on the page directly – Aravona Jul 4 '18 at 13:35
0

In the end I achieved this in my getJsonConfig override class using:

$ids = Mage::getResourceSingleton('catalog/product_type_configurable')->getChildrenIds($currentProduct->getId());

$info['options'][$i] = array(
    'id'        => $value['value_index'],
    'label'     => $value['label'],
    'price'     => $configurablePrice,
    'oldPrice'  => (isset($simplePrices['old']) ? $simplePrices['old'] : 0),
    'products'  => $productsIndex,
);

foreach($ids[0] as $id){

    $_product = Mage::getModel('catalog/product')->load($id);

    if(in_array($_product->getId(),$productsIndex)){
        $info['options'][$i]['short_description'] = $_product->getShortDescription();
    }
}

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.