Esempio n. 1
0
 /**
  * Retrieves a list of SKU's with low inventory qty
  *
  * {@inheritdoc}
  */
 public function getLowStockItems($lowStockCriteria)
 {
     /** @var \Magento\CatalogInventory\Model\Resource\Stock\Status\Collection $itemCollection */
     $itemCollection = $this->itemsFactory->create();
     $itemCollection->addWebsiteFilter($this->scopeResolver->getScope());
     $itemCollection->addQtyFilter($lowStockCriteria->getQty());
     $itemCollection->setCurPage($lowStockCriteria->getCurrentPage());
     $itemCollection->setPageSize($lowStockCriteria->getPageSize());
     $countOfItems = $itemCollection->getSize();
     $listOfSku = [];
     foreach ($itemCollection as $item) {
         $listOfSku[] = $item->getSku();
     }
     $this->lowStockResultBuilder->setSearchCriteria($lowStockCriteria);
     $this->lowStockResultBuilder->setTotalCount($countOfItems);
     $this->lowStockResultBuilder->setItems($listOfSku);
     return $this->lowStockResultBuilder->create();
 }
Esempio n. 2
0
 /**
  * @expectedException \Magento\Framework\Exception\State\InitException
  */
 public function testGetScopeWithInvalidScope()
 {
     $scopeMock = new \StdClass();
     $this->_storeManagerMock->expects($this->once())->method('getWebsite')->with(0)->will($this->returnValue($scopeMock));
     $this->assertEquals($scopeMock, $this->_model->getScope());
 }