1

We have a configurable product called with sku TEST and under it are simple products (for example) red-ven1, red-ven2, blue-ven3, etc. The configurable product itself does not have a price but each simple product does. I need to retrieve the price for the simple product based on the attributes that are selected. So I need the price for red product with vendor 2. How do I get this specific price? I am currently trying to dynamically display the price next to the vendor attribute (so vendor attribute is not selected). Will I have to "invisibly" select the vendor attribute value to get the price? Please advise.

Currently Trying:

<?php $_product    = $this->getProduct(); ?>
<?php $_price = $_taxHelper->getPrice($_product, $_product->getPrice()) ?>

<script>
var price = <?=$_price ?>;

            /...lots of non-applicable code
            for(var i=0; i < IDs.length; i++)//traversing the vendor detail nodes
            {   
                //Invisibly make selection of vendor so as to gather correct price
                var optionToSelect = $j('option', '#attribute136').filter(function() {
                    return $j(this).text().indexOf(data[i].vendor_id) != -1;
                }).val();
                var vals = $j('#attribute136').val() || [];
                vals.push(optionToSelect);
                $j('#attribute136').val(vals);

            $j('.details'+data[i].vendor_id).append('<li class="priceBlock">$'+price+'</li>');
            }

        }); 
</script>
  • When I var_dump($_product->debug()); I see the simple products and their individual price... I'm just not sure what filter to put on that to retrieve the price. – CaitlinHavener May 23 '13 at 14:41
  • Did you get any solution for your question? I need some help for the same issue. – Doodu Apr 4 '17 at 18:27
4

There are two extension which does this for you:

Simple Configurable Products

http://www.magentocommerce.com/magento-connect/simple-configurable-products.html

BCP - Better Configurable Products

http://www.magentocommerce.com/magento-connect/better-configurable-products.html

  • Hi, is there any extension for magento 1.9.1? Searching for a long time. – Doodu Apr 4 '17 at 14:25
  • I guess both should work. Did you try it? – Fabian Blechschmidt Apr 4 '17 at 15:01
  • Yes tried. not working. – Doodu Apr 4 '17 at 17:55
0

Check following link. This helps you. In this post can get product id of selected simple product of configurable product. And using that simple product id you can get price, qty, sku, etc...

Simple product of configurable product

0

I did this in list.phtml. It's a hack, but it works (and it's free!)

<?php
foreach ($_productCollection as $_product):
    $_modifiedProduct = $_product;
    ?>
    <?php
    if ($_product->isConfigurable()) {
        $conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
        $simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
        $appliedFilters = Mage::getSingleton('catalog/layer')->getState()->getFilters();

        $itemArr = array();
        foreach ($appliedFilters as $item) {

            $itemArr[] = $item->getLabel();
        }

        $attributesToFilter = array();
        foreach ($simple_collection as $simple_product) {

            $productModel = Mage::getModel('catalog/product')->setProduct($simple_product);

            $sizeAttr = $productModel->getResource()->getAttribute("size");
            $qualityAttr = $productModel->getResource()->getAttribute("quality");
            $attributesToFilter[] = $sizeAttrName = $sizeAttr->getSource()->getOptionText($simple_product->getSize());
            $attributesToFilter[] = $qualityAttrName = $qualityAttr->getSource()->getOptionText($simple_product->getQuality());

            sort($attributesToFilter);
            sort($itemArr);

            if ($attributesToFilter == $itemArr) {
                $_modifiedProduct = $simple_product;
                break(1);
            }
            unset($attributesToFilter);
        }
    }
// continue in foreach.
endforeach;
?>

Now you can show price like this:

 <?php echo $this->getPriceHtml($_modifiedProduct, true) ?>
  • That is pretty hideous in terms of performance however, loading a collection for every product in the list would be pretty heavy – lukefowell Aug 8 '14 at 13:50
  • I agree, it's not optimized for a large amount of products, it may however give an idea of how it can be done. – munkholm Aug 18 '14 at 20:17

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.