magento获得产品的custom option信息 Getting all custom options of a product
2017-04-20 16:26
465 查看
Custom options are the options that can be added to any product, which gives an option for the user of the site to select what type of product they actually want. Here is a scenario where custom option can be helpful. If you have a product say ball and your
stores sells plastic,rubber,glass balls. So you need to give the user to select what type of ball they actually want. Yes, you can do this by using configurable product as well, but why create an attribute for one product only! In this case custom option might
be very helpful.
Here’s the code to get the all the custom options of a product. Please see that you need to specify the id of the product for which you are retriving custom option for. I’ve echoed some text as well to give you an idea what exactly you are getting in each
loop.
$product = Mage::getModel("catalog/product")->load(167);
$i = 1;
echo "<pre>";
foreach ($product->getOptions() as $o) {
echo "<strong>Custom Option:" . $i . "</strong><br/>";
echo "Custom Option TYPE: " . $o->getType() . "<br/>";
echo "Custom Option TITLE: " . $o->getTitle() . "<br/>";
echo "Custom Option Values: <br/>";
// Getting Values if it has option values, case of select,dropdown,radio,multiselect
$values = $o->getValues();
foreach ($values as $v) {
print_r($v->getData());
}
$i++;
echo "----------------------------------<br/>";
}
相关文章推荐
- Magento How To Display Product Custom Option On list.phtml
- magento How to get all associated children product of a configurable product
- Magento How To Display Product Custom Option On list.phtml
- magento custom product api(4) --- getallproducts
- Magento产品更新通知顾客插件-Product Updates Notifications
- Magento快速添加产品的插件 - Quick Product Adder Client
- magento 1.4 -- 推荐插件 -- 产品页计算运费插件(Estimate Shipping on the Product Page)
- magento -- 根据产品的sku获得产品
- 收录国外造船信息-Pursuit of a product work breakdown structure (PWBS)
- 获得当前分类ID,产品详细信息页面得到当前产品默认商店的的商品名称
- 修改magento页面的title,description等------------进而可以写一个descroption数组,让description随机生成-----方便seo,节省在添加产品的时候添加descrition浪费时间
- magento -- 获得产品所属于的分类
- Magento中在产品页中显示Custom Option中定义的SKU
- Any chance of getting rid of the all_load requirement for the iOS framework?
- 在Magento产品管理中添加额外信息
- magento 产品详细页面的下拉框,下拉条,改成点击方式,从数据库中提取下拉框中的信息
- 在VC中如何获得USB设备的Product ID,Vendor ID等信息
- magento -- 可配置产品页获得所属简单产品的库存
- Magento All kinds of Theme
- 插件: images and custom options,magento添加多图片,自定义选项custom options,catelog,分类的插件以及使用方法!!!