Skip to main content
added 4 characters in body
Source Link
Ketan Borada
  • 2.7k
  • 2
  • 37
  • 78
<?php 

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$item = $objectManager->create('Magento\Catalog\Model\Product');
$quoteId = $objectManager-> create('Magento\Checkout\Model\Session')->getQuoteId();
$cartData = $objectManager->create('Magento\Quote\Model\QuoteRepository')->get($quoteId)->getAllVisibleItems(); 

foreach($items as $item) {
    //$item = $item->load($item->getProductId()); load product

    if($item->getSku>getData('custom_attribute')=='SM100'){
        echo 'ID: '.$item->getProductId().'<br />';
        echo 'Name: '.$item->getName().'<br />';
        echo 'Sku: '.$item->getSku().'<br />';
        echo 'Quantity: '.$item->getQty().'<br />';
        echo 'Price: '.$item->getPrice().'<br />';
        echo "<br />";   
    }


  }
<?php 

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$item = $objectManager->create('Magento\Catalog\Model\Product');
$quoteId = $objectManager-> create('Magento\Checkout\Model\Session')->getQuoteId();
$cartData = $objectManager->create('Magento\Quote\Model\QuoteRepository')->get($quoteId)->getAllVisibleItems(); 

foreach($items as $item) {
    //$item = $item->load($item->getProductId()); load product

    if($item->getSku()=='SM100'){
        echo 'ID: '.$item->getProductId().'<br />';
        echo 'Name: '.$item->getName().'<br />';
        echo 'Sku: '.$item->getSku().'<br />';
        echo 'Quantity: '.$item->getQty().'<br />';
        echo 'Price: '.$item->getPrice().'<br />';
        echo "<br />";   
    }


  }
<?php 

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$item = $objectManager->create('Magento\Catalog\Model\Product');
$quoteId = $objectManager-> create('Magento\Checkout\Model\Session')->getQuoteId();
$cartData = $objectManager->create('Magento\Quote\Model\QuoteRepository')->get($quoteId)->getAllVisibleItems(); 

foreach($items as $item) {
    $item = $item->load($item->getProductId());

    if($item->getData('custom_attribute')=='SM100'){
        echo 'ID: '.$item->getProductId().'<br />';
        echo 'Name: '.$item->getName().'<br />';
        echo 'Sku: '.$item->getSku().'<br />';
        echo 'Quantity: '.$item->getQty().'<br />';
        echo 'Price: '.$item->getPrice().'<br />';
        echo "<br />";   
    }


  }
Source Link
Ketan Borada
  • 2.7k
  • 2
  • 37
  • 78

<?php 

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$item = $objectManager->create('Magento\Catalog\Model\Product');
$quoteId = $objectManager-> create('Magento\Checkout\Model\Session')->getQuoteId();
$cartData = $objectManager->create('Magento\Quote\Model\QuoteRepository')->get($quoteId)->getAllVisibleItems(); 

foreach($items as $item) {
    //$item = $item->load($item->getProductId()); load product

    if($item->getSku()=='SM100'){
        echo 'ID: '.$item->getProductId().'<br />';
        echo 'Name: '.$item->getName().'<br />';
        echo 'Sku: '.$item->getSku().'<br />';
        echo 'Quantity: '.$item->getQty().'<br />';
        echo 'Price: '.$item->getPrice().'<br />';
        echo "<br />";   
    }


  }