0
 protected $cart;

 \Magento\Checkout\Model\Cart $cart,

 $this->cart = $cart;

Why returns null ?

$this->cart->getQuote()->getAllItems();

and

$this->cart->getQuote()->getAllVisibleItems();

And with session same result.

  • where you have call it? – Amit Bera Apr 30 at 17:24
  • Do you mean in frontend or backend or in which files ? – Robinio Tor Apr 30 at 17:30
  • on which files you inject the class \Magento\Checkout\Model\Cart $cart, – Amit Bera Apr 30 at 17:43
  • vendor/module/Block/Adminhtml/CartInfo/Index.php – Robinio Tor Apr 30 at 17:45
  • $this->cart->getQuote()->getItemsCollection(); returns all cart info but i need only visible items – Robinio Tor Apr 30 at 17:47
0

You can not use the frontend Cart class for backend and vendor/module/Block/Adminhtml/CartInfo/Index.php is a backend class.

If you need to use \Magento\Backend\Model\Session\Quote for getting current admin quote and it will work at the admin order create page.

  • Can You send as get from this carts information ? thanks very much – Robinio Tor Apr 30 at 17:59
  • Can you please describe your requirement? – Amit Bera May 1 at 12:23
  • I created a page in the admin panel and there I need to show all the products that are currently in the basket – Robinio Tor May 2 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.