public function testGetIsQtyTypeIds()
 {
     $configAll = [1 => ['is_qty' => true], 2 => ['is_qty' => false], 3 => []];
     $resultAll = [1 => true, 2 => false, 3 => false];
     $resultTrue = [1 => true];
     $resultFalse = [2 => false, 3 => false];
     $this->config->expects($this->once())->method('getAll')->will($this->returnValue($configAll));
     $this->assertEquals($resultAll, $this->model->getIsQtyTypeIds());
     $this->assertEquals($resultTrue, $this->model->getIsQtyTypeIds(true));
     $this->assertEquals($resultFalse, $this->model->getIsQtyTypeIds(false));
 }
Beispiel #2
0
 /**
  * Load some inventory configuration settings
  *
  * @return void
  */
 protected function _initConfig()
 {
     if (!$this->_isConfig) {
         $configMap = array('_isConfigManageStock' => \Magento\CatalogInventory\Model\Stock\Item::XML_PATH_MANAGE_STOCK, '_isConfigBackorders' => \Magento\CatalogInventory\Model\Stock\Item::XML_PATH_BACKORDERS, '_configMinQty' => \Magento\CatalogInventory\Model\Stock\Item::XML_PATH_MIN_QTY, '_configNotifyStockQty' => \Magento\CatalogInventory\Model\Stock\Item::XML_PATH_NOTIFY_STOCK_QTY);
         foreach ($configMap as $field => $const) {
             $this->{$field} = (int) $this->_scopeConfig->getValue($const, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
         }
         $this->_isConfig = true;
         $this->_stock = $this->_stockFactory->create();
         $this->_configTypeIds = array_keys($this->stockItemService->getIsQtyTypeIds(true));
     }
 }
Beispiel #3
0
 /**
  * Add filter by product types from config - only types which have QTY parameter
  *
  * @return $this
  */
 public function filterByIsQtyProductTypes()
 {
     $this->filterByProductType(array_keys(array_filter($this->stockItemService->getIsQtyTypeIds())));
     return $this;
 }