0
我想添加產品到購物車,並選擇了訂購產品的選項。 作爲示例,我訂購了一個可配置產品,其中可用選項爲S,M,L。我選擇M並訂購它。現在我想拉這個訂單,並以編程方式再次移動到購物車。 我在許多不同的過程中嘗試了這一點,但我還沒有成功。請任何人向我建議如何做到這一點?Magento從訂購商品中添加可配置產品到購物車
我想添加產品到購物車,並選擇了訂購產品的選項。 作爲示例,我訂購了一個可配置產品,其中可用選項爲S,M,L。我選擇M並訂購它。現在我想拉這個訂單,並以編程方式再次移動到購物車。 我在許多不同的過程中嘗試了這一點,但我還沒有成功。請任何人向我建議如何做到這一點?Magento從訂購商品中添加可配置產品到購物車
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;
}
}
您提供任何代碼來獲得尺寸大小的選擇ID證明你的努力爲您解決問題 – hindmost