我会给你一个产品的例子.假设您知道您所需产品的Sku(例如,让它成为“ABCDE”).所以您将能够获得该产品的ID.
原文链接:https://www.f2er.com/php/140138.html代码将有点像:
$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>'; }
我想这将让你开始.
根据变量“$optionType”中的选项类型,您需要调用另一个嵌套的“foreach”循环.我已经在文本框,文本字段,下拉列表,但不是其他类型.所以我想你需要自己做更多的RnD.