我在我要發送的業務情景中使用產品選定的購物車頁面中的自定義選項SKU已創建陣列,以便在自定義選項的情況下發送到購物車。如何發送產品選定的自定義選項Sku字段到Magento中的購物車頁面
這裏有一個函數叫做getProductOptions()
,其中產品選項數組被創建併發送到購物車。此時,我想將選定的自定義選項SKU字段發送到購物車。
我有以下代碼:
public function getProductOptions()
{
$options = array();
if ($optionIds = $this->getItem()->getOptionByCode('option_ids')) {
$options = array();
foreach (explode(',', $optionIds->getValue()) as $optionId) {
if ($option = $this->getProduct()->getOptionById($optionId)) {
//echo $optionId;
echo "hhhhhhhhhhhhh";
//print_r($option->getId());
//echo Mage::getModel('catalog/product')->getOptionSku($option);
//die();
//print_r($option->getOptionSku());
//echo Mage_Catalog_Model_Product_Option_Type_Select::getOptionSku());
$quoteItemOption = $this->getItem()->getOptionByCode('option_' . $option->getId());
//echo $option->getQuoteItemOption($quoteItemOption);
$group = $option->groupFactory($option->getType())
->setOption($option)
->setQuoteItemOption($quoteItemOption);
$options[] = array(
'label' => $option->getTitle(),
'value' => $group->getFormattedOptionValue($quoteItemOption->getValue()),
'print_value' => $group->getPrintableOptionValue($quoteItemOption->getValue()),
'option_id' => $option->getId(),
'option_type' => $option->getType(),
'custom_view' => $group->isCustomizedView(),
'option_sku'=>//What should i call here to send Selected option SKU to this Array
);
}
}
if ($addOptions = $this->getItem()->getOptionByCode('additional_options')) {
$options = array_merge($options, unserialize($addOptions->getValue()));
}
}
return $options;
}
你這個代碼添加到法師/結算/塊/車/項目/ Renderer.php? – Sam 2012-08-16 16:25:38