Example #1
0
 /**
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  * @magentoDataFixture Magento/Customer/_files/customer.php
  * @magentoDataFixture Magento/Customer/_files/quote.php
  */
 public function testUpdateAction()
 {
     $items = $this->quoteItemCollectionFactory->create();
     $itemId = $items->getAllIds()[0];
     $this->getRequest()->setParam('customer_id', 1);
     $this->getRequest()->setParam('website_id', 1);
     $this->getRequest()->setParam('id', $itemId);
     $this->dispatch('backend/customer/cart_product_composite_cart/update');
     $this->assertRedirect($this->stringContains('catalog/product/showUpdateResult'));
 }
 public function testGetItemsCollection()
 {
     $itemCollectionMock = $this->getMockBuilder('Magento\\Quote\\Model\\ResourceModel\\Quote\\Collection')->disableOriginalConstructor()->setMethods(['setQuote'])->getMock();
     $this->quoteItemCollectionFactoryMock->expects($this->once())->method('create')->willReturn($itemCollectionMock);
     $this->extensionAttributesJoinProcessorMock->expects($this->once())->method('process')->with($this->isInstanceOf('Magento\\Quote\\Model\\ResourceModel\\Quote\\Collection'));
     $itemCollectionMock->expects($this->once())->method('setQuote')->with($this->quote);
     $this->quote->getItemsCollection();
 }
 /**
  * Add cart info to collection
  *
  * @return $this
  */
 public function addCartInfo()
 {
     foreach ($this->getItems() as $item) {
         try {
             $quote = $this->quoteRepository->getForCustomer($item->getId());
             $totals = $quote->getTotals();
             $item->setTotal($totals['subtotal']->getValue());
             $quoteItems = $this->_quoteItemFactory->create()->setQuoteFilter($quote->getId());
             $quoteItems->load();
             $item->setItems($quoteItems->count());
         } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
             $item->remove();
         }
     }
     return $this;
 }
Example #4
0
 /**
  * Retrieve quote items collection
  *
  * @param bool $useCache
  * @return  \Magento\Eav\Model\Entity\Collection\AbstractCollection
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function getItemsCollection($useCache = true)
 {
     if ($this->hasItemsCollection()) {
         return $this->getData('items_collection');
     }
     if (null === $this->_items) {
         $this->_items = $this->_quoteItemCollectionFactory->create();
         $this->extensionAttributesJoinProcessor->process($this->_items);
         $this->_items->setQuote($this);
     }
     return $this->_items;
 }