Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento从订单项目向购物车添加可配置产品_Php_Magento_Magento 1.7 - Fatal编程技术网

Php Magento从订单项目向购物车添加可配置产品

Php Magento从订单项目向购物车添加可配置产品,php,magento,magento-1.7,Php,Magento,Magento 1.7,我想将产品添加到购物车中,并选择订购产品的选项。 例如,我订购了一款可配置产品,其中可用选项为S、M、L。我选择M并对其进行排序。现在我想拉这个订单,并以编程方式再次移动到购物车。 我在许多不同的过程中尝试过这一点,但我还没有成功。有人能给我建议怎么做吗?, 请尝试使用eav Attibe以编程方式创建购物车url获取大小的选项id <?php $ConfigProduct=Mage::getModel('catalog/product')->load($cpid); $GetAl

我想将产品添加到购物车中,并选择订购产品的选项。 例如,我订购了一款可配置产品,其中可用选项为S、M、L。我选择M并对其进行排序。现在我想拉这个订单,并以编程方式再次移动到购物车。 我在许多不同的过程中尝试过这一点,但我还没有成功。有人能给我建议怎么做吗?

, 请尝试使用eav Attibe以编程方式创建购物车url获取大小的选项id

 <?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;
    }
}

您必须提供任何代码来证明您为解决问题所做的努力