/************************************************************
get All Custom option Individual By Product Id
**************************************************************
/* ==========Get OptionID ======== */
$_productId=1;
$productDub = Mage::getModel('catalog/product')->load($_productId);
//$productDub = Mage::getModel('catalog/product')->load(167);
$optionCollection=array();
foreach ($productDub->getOptions() as $o) {
$optionType = $o->getType();
// echo 'Type = '.$optionType;
if ($optionType == 'drop_down') {
$values ='';
$values = $o->getValues();
$optionFinish=array();
$i=0;
$selectOp=array();
foreach ($values as $k => $v) {
$optionOder=$o->getSort_order();
$default_title=$o->default_title;
$v->getData();
$option_type_id=$v->option_type_id;
$option_id=$v->option_id;
$title=$v->title;
$price=$v->price;
$price_type=$v->price_type;
$sort_order=$v->sort_order;
for($i=0;$i<count($expOp);$i++){
$expOp2=explode(',',$expOp[$i]);
if($optionOder==$expOp2[0]){
if($expOp2[1]==$title){
$optionValId[$option_id]=$option_type_id;
$selectOp=$optionValId;
}
}
}
}
}else if($optionType=='field'){
$values='';
$v = $o->getData();
//print_r($v);
$default_title=$o->default_title;
$option_type_id=$v['option_type_id'];
$option_id=$v['option_id'];
$title=$v['title'];
$price=$v['price'];
if($title=="width"){
$width_option_id= $option_id;
}
if($title=="height"){
$height_option_id=$option_id;
}
}else {
//print_r($o);
}
}
/* ==========END Get OptionID ======== */
Thank you for sharing such a wonderful Post. This post is very informative for people. Keep posting.
ReplyDeletePhp Web Development Company Bangalore | Ecommerce Bangalore | Internet Marketing Company in Bangalore | Magento Experts In India