I have written custom wishlist which will display its items when customer logins. If customer adds product other than config products, my wishlist is working fine, but when customer adds configurable product, I am getting error.
Fatal error: Call to undefined method Magento\Catalog\Model\Product\Type\Virtual::getConfigurableAttributes() in C:\xampp\htdocs\cw1\campingworld2\vendor\magento\module-configurable-product\Model\Plugin\AfterProductLoad.php on line 66
I checked with this file, this line is getting Configurable product attributes. My code is
<span><?php echo $block->escapeHtml($product->getSku()); ?></span>
<?php
// $priceBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\ListProduct');
// getting $product object, passed $product object inside function
// echo $priceBlock->getProductPrice($product);
$priceHelper = $objectManager->get('Magento\Framework\Pricing\Helper\Data'); // Instance of Pricing Helper
//$finalPrice = $block->getItemPrice($product->getFinalPrice());
$finalPrice = $priceHelper->currency($product->getFinalPrice(), true, false);
$oldPrice = $priceHelper->currency($product->getPrice(), true, false);
echo __("SALE ");
echo $block->escapeHtml($finalPrice);
?>
<br>
<?php if ($product->getFinalPrice() < $product->getPrice()): ?>
<span class="price-off">
<span>
<?php $oldPrice = $priceHelper->currency($product->getPrice(), true, false);
echo $block->escapeHtml($oldPrice);
?>
</span>
<?php if ($finalPrice && $oldPrice): ?>
<?php echo __("SAVE ") ?>
<?php $priceOff = $block->getPriceOff($product->getPrice(), $product->getFinalPrice());
$priceOff = $block->escapeHtml($priceHelper->currency($priceOff, true, false));
echo substr($priceOff, 1);
echo __("%") ?>
<?php endif; ?>
</span>
<?php endif; ?>
I debug it and found, If i will use $Product->getSku();
I am getting error, but if used $Product->getData('sku');
its working.
Please tell me how to get configurable product data.