protected $_customOption;
\Magento\Catalog\Model\Product\Option $customOption,
$this->_customOption = $customOption;
public function customOption($product)
{
$custom = $this->_customOption->getProductOptionCollection($product);
if(!empty($custom)):
foreach($custom as $option):
$values = $option->getValues();
if(!empty($values)):
foreach($values as $value):
$valueData[] = $value->getData();
endforeach;
return $valueData;
else:
return 'Product has no custom option value';
endif;
endforeach;
else:
return 'Product does not have custom options';
endif;
}
\Magento\Catalog\Model\Product\Option $customOption,
$this->_customOption = $customOption;
public function customOption($product)
{
$custom = $this->_customOption->getProductOptionCollection($product);
if(!empty($custom)):
foreach($custom as $option):
$values = $option->getValues();
if(!empty($values)):
foreach($values as $value):
$valueData[] = $value->getData();
endforeach;
return $valueData;
else:
return 'Product has no custom option value';
endif;
endforeach;
else:
return 'Product does not have custom options';
endif;
}
No comments:
Post a Comment