B-219 Sec-55 Noida, India
+918010221733

Want to add to cart configrurable product instead of drop down–

<!– FOR THE ASSOCIATED PRODUCTS–>
<?php  $config_product_id = Mage::registry(‘current_product’)->getId();?>
<?php  //if ($_product->isSaleable() && count($_attributes)):?>
<?php
 $product=Mage::getModel(‘catalog/product’)->load($config_product_id);
  $productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
   $attributeOptions = array();
     $ids = Mage::getModel(‘catalog/product_type_configurable’)->getChildrenIds($product->getId()); //get the children ids through a simple query
$_subproducts = Mage::getModel(‘catalog/product’)->getCollection()
    ->addAttributeToFilter(‘entity_id’, $ids)
    ->addAttributeToSelect(‘*’);
    $prod_img=array();
   foreach($_subproducts as $_sub_prod){
    $prod_name [] = $_sub_prod->getName();
//    echo  Mage::helper(‘catalog/image’)->init($_sub_prod, ‘small_image’)->resize(50,50);;
    $prod_img[] = $_sub_prod->getImageUrl();
    $asso_prod_id[] = $_sub_prod->getId();
    }
 //  print_r($img);die;
    $i=0;$j=0;
   foreach ($productAttributeOptions as $productAttribute) {
    foreach ($productAttribute[‘values’] as $attribute) {?>
     <form id=”childproduct_addtocart_form_<?php echo $config_product_id?>” onsubmit=”return addToCart(this);” method=”post” action=”<?php echo Mage::getBaseUrl();?>checkout/cart/add?product=<?php echo $config_product_id?>&super_attribute[<?php echo $productAttribute[‘attribute_id’]; ?>]=<?php echo $attribute[‘value_index’]?>”>
       <?php echo $this->getBlockHtml(‘formkey’) ?>
<?php

      echo $prod_name[$i];
    //  echo $prod_img[$j].’-‘.$i;
      echo  “<img src=”.$prod_img[$j].” width=’100px’>”;
    echo “price: “.$attribute[‘pricing_value’]. “—“. ” Color: “.$attribute[‘store_label’].” —- “.”” ;
      
     ?>   
     <input id=”qty-<?php echo $asso_prod_id;?>” class=”input-text qty” type=”number” title=”Aantal” value=”1″ maxlength=”12″ max=”100″ min=”0″ name=”qty”>
       <input type=”hidden” value=”<?php echo $config_product_id?>” name=”product”>
       <input type=”hidden” value=”” name=”related_product”>
        <input type=”hidden” value=”<?php echo $attribute[‘value_index’]?>” name=”super_attribute[<?php echo $productAttribute[‘attribute_id’]; ?>]”>
     <button class=”cart_button” title=”In winkelwagen” type=”submit”>Add To Cart</button>
     </form>
<?php
    $i++;$j++;}
}
//echo ‘<pre>’;

    //print_r($_subproducts);
   

?>

(Visited 48 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.