2014-02-21 163 views
0

我想添加产品到购物车,并选择了订购产品的选项。 作为示例,我订购了一个可配置产品,其中可用选项为S,M,L。我选择M并订购它。现在我想拉这个订单,并以编程方式再次移动到购物车。 我在许多不同的过程中尝试了这一点,但我还没有成功。请任何人向我建议如何做到这一点?Magento从订购商品中添加可配置产品到购物车

+2

您提供任何代码来获得尺寸大小的选择ID证明你的努力为您解决问题 – hindmost

回答

0

Supravat, 请尝试使用EAV attibute的programically创建一个购物车的URL

<?php 
$ConfigProduct=Mage::getModel('catalog/product')->load($cpid); 
$GetAllowAttributes=$ConfigProduct->getTypeInstance(true) 
      ->getConfigurableAttributes($ConfigProduct); 

foreach ($GetAllowAttributes() as $attribute) { 
       $productAttribute = $attribute->getProductAttribute(); 
       $attribute_code= $productAttribute->getAttributeCode(); 
       $attributeid=$productAttribute->getId(); 
       break; 


} 
$attribute_details = Mage::getSingleton("eav/config")->getAttribute("catalog_product", $attribute_code); 
$options = $attribute_details->getSource()->getAllOptions(false); 
foreach($options as $option){ 
    // print_r($option) and find all the elements 
    //echo $option["value"]; 
    //echo $option["label"]; 
    if($option["label"]==$youlabel){ 
     $opid=$option["value"]; 
     $cartUrl=Mage::helper('checkout/cart')->getAddUrl($ConfigProduct).'?super_attribute['.$attributeid.']='.$option["value"].'&qty=1'; 
     break; 
    } 
} 
相关问题