我创建了一个模块,用于将产品发送到另一个具有json
结构的服务器,如此
{
name: "Black Nolita Cami",
code: "877",
sku: "wbk002c",
price: "150.0000",
sale_price: "wbk002c",
discount: "",
quantity: "0.0000",
weight: null,
url: "black-nolita-cami.html"}
但我有另一个字段变体,我已将所有产品变体放在那里如何操作?
答案 0 :(得分:1)
这可能会让你开始朝着正确的方向前进......
$productSku = "ABCDE";
$product = Mage::getModel('catalog/product');
$productId = $product->getIdBySku( $productSku );
$product->load($productId);
/**
* In Magento Models or database schema level, the product's Custom Options are
* executed & maintained as only "options". So, when checking whether any product has
* Custom Options or not, we should check by using this method "hasOptions()" only.
*/
if($product->hasOptions()) {
echo '<pre>';
foreach ($product->getOptions() as $o) {
$optionType = $o->getType();
echo 'Type = '.$optionType;
if ($optionType == 'drop_down') {
$values = $o->getValues();
foreach ($values as $k => $v) {
print_r($v);
}
}
else {
print_r($o);
}
}
echo '</pre>';
}