- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2017
02:18 AM
12-28-2017
02:18 AM
With some debugging and effort the thing was discovered, that the following code snippet is the solution to the problem.
$customOptions = $objectManager->get('Magento\Catalog\Model\Product\Option')
->getProductOptionCollection($_product);
if (empty($customOptions)) { //check if product has custom options. If it doesn't go to the next product
continue;
}
foreach($customOptions as $option) {
$values = $option->getValues();
if (empty($values)) { //check if option has values (Option can have values only if option type is checkbox, radio, multiselect or drop-down)
continue;
}
foreach($values as $value) {
$valueData = $value->getData(); //do whatever you want will value data
}
}
In order to get, for instance, option value title use this:
foreach($customOptions as $option) {
$values = $option->getValues();
if (empty($values)) { //check if option has values (Option can have values only if option type is checkbox, radio, multiselect or drop-down)
continue;
}
foreach($values as $value) {
$valueTitle = $value->getTitle();
}
}
Cheers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2017
02:40 AM
12-28-2017
02:40 AM
Re: Magento2 Get product custom options on product list page
@dmoisej your the man!! woow thank you so much. Also thank you so much for debugging. That solves my problem. Yayyy!!!!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2018
10:05 PM
04-23-2018
10:05 PM
Re: Magento2 Get product custom options on product list page
Thank you very much
- « Previous
-
- 1
- 2
- Next »