I am trying to show the attribute's dropdown values selected in product. For that I am using this way.
<?php $parentIds = $objectManager->create('Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable')->getParentIdsByChild($_product->getId());
if(count($parentIds)>0 && $_product->getTypeId() == "simple")
{
/*?><script>console.log('<?php echo $_product->getSku(); ?>')</script><?php */
}
else {
foreach ($_productCollection as $_product) :
$_p = $objectManager->get('Magento\Catalog\Model\Product')->load($_product->getId());
$productList[] = $_p;
$priceRuleCats = $_p->getprice_rule_category();
if(!empty($priceRuleCats)){
$priceRuleList = array_unique(array_merge($priceRuleList,explode(',',$priceRuleCats)));
}
endforeach;
// save the full list
$fullList = $productList;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$price_rules = $objectManager->get('Startupready\PriceRules\Model\Quantitybreaks');
$price_rules->load($priceRuleList);
$price_rules->getPricingTables();
$current_table = 0;
$size_options = array();
$price_breaks = array();
// use first product from loop to see what the size options are & load price breaks for those options
$firstProduct = array_shift($productList);
// this product's price rule category
$price_rule_category = $firstProduct->getprice_rule_category();
// loop through simple products
$conf = $objectManager->create('Magento\ConfigurableProduct\Model\Product\Type\Configurable')->setProduct($firstProduct);
$simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
foreach($simple_collection as $simple){
echo $simple->getsize_option();
//also i tried like this
//echo "<pre>"; print_r($simple['size_option']); echo "</pre>";
}
?>
but when I am putting my code inside the list.phtml file, no any products are displaying on this page.
Meanwhile I am just trying to get that product attribute inside this array so that if a product have assigned this values (doropdown values) then I'll show those values in frontend. Kindly please help me to do this. Thank in advance.