I got two solutions for this issue ! , i think 1st solution is better, because it reduce loading and make fast response in our application last solution is the final solution but it make your application slow .Thank you for the supporters to find this final solution
Solution 1 :
Create a Helper Class file and paste below code
app/code/{vendor}/{module}/Helper/Data.php
<?php
namespace Wac\DropPin\Helper;
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
protected $productRepository;
public function __construct(
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository
) {
$this->productRepository = $productRepository;
}
public function loadMyProduct($sku)
{
$productData = $this->productRepository->get($sku);
return $productWeight = $productData->getResource()->getAttribute('weight_spices')->getFrontend()->getValue($productData) ? $productData->getResource()->getAttribute('weight_spices')->getFrontend()->getValue($productData) : $productData->getResource()->getAttribute('weight_oil')->getFrontend()->getValue($productData);
}
}
?>
Then Edit default.phtml file and paste below code 'l'm simply pass the sku on my function in this section'
app/code/{vendor}/{module}/view/frontend/templates/cart/item/default.phtml
<?php
$sku = $_item->getProduct()->getSku();
$customHelper = $this->helper('Wac\DropPin\Helper\Data');
echo $product = $customHelper->loadMyProduct($sku);
?>
Finally Run all commands
Solution 2 :
(Not a good approach, but my last solution ) to print Product attribute values Separately like 100g,1 Litter,1kg etc.. using Object manager
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$item = $this->getItem();
$productFactory = $objectManager->create('\Magento\Catalog\Model\ProductRepository');
$productData = $productFactory->get($_item->getSku($item));
$productHsn = $productData->getHsn();
echo $productWeight = $productData->getResource()->getAttribute('weight_spices')->getFrontend()->getValue($productData) ? $productData->getResource()->getAttribute('weight_spices')->getFrontend()->getValue($productData) : $productData->getResource()->getAttribute('weight_oil')->getFrontend()->getValue($productData);