Пример #1
0
 /**
  * @param array $config
  * @param float $expected
  * @dataProvider getMinSaleQtyDataProvider
  */
 public function testGetMinSaleQty($config, $expected)
 {
     $groupId = $config['customer_group_id'];
     $useConfigMinSaleQty = $config['use_config_min_sale_qty'];
     $minSaleQty = $config['min_sale_qty'];
     $property = new \ReflectionProperty($this->item, '_customerGroupId');
     $property->setAccessible(true);
     $property->setValue($this->item, $groupId);
     $property = new \ReflectionProperty($this->item, '_minSaleQtyCache');
     $property->setAccessible(true);
     $this->assertEmpty($property->getValue($this->item));
     $this->setDataArrayValue('use_config_min_sale_qty', $useConfigMinSaleQty);
     if ($useConfigMinSaleQty) {
         $this->catalogInventoryMinsaleqty->expects($this->once())->method('getConfigValue')->with($this->equalTo($groupId))->will($this->returnValue($minSaleQty));
     } else {
         $this->setDataArrayValue('min_sale_qty', $minSaleQty);
     }
     $this->assertSame($expected, $this->item->getMinSaleQty());
     // check lazy load
     $this->assertSame($expected, $this->item->getMinSaleQty());
 }
Пример #2
0
 /**
  * @param string|array $value
  * @param string $result
  * @dataProvider makeStorableArrayFieldValueDataProvider
  */
 public function testMakeStorableArrayFieldValue($value, $result)
 {
     $this->assertSame($result, $this->minsaleqty->makeStorableArrayFieldValue($value));
 }
Пример #3
0
 /**
  * Retrieve Minimum Qty Allowed in Shopping Cart or NULL when there is no limitation
  *
  * @return float|null
  */
 public function getMinSaleQty()
 {
     $customerGroupId = $this->getCustomerGroupId();
     if (!isset($this->_minSaleQtyCache[$customerGroupId])) {
         if ($this->getUseConfigMinSaleQty()) {
             $minSaleQty = $this->_catalogInventoryMinsaleqty->getConfigValue($customerGroupId);
         } else {
             $minSaleQty = $this->getData('min_sale_qty');
         }
         $this->_minSaleQtyCache[$customerGroupId] = empty($minSaleQty) ? 0 : (double) $minSaleQty;
     }
     return $this->_minSaleQtyCache[$customerGroupId] ? $this->_minSaleQtyCache[$customerGroupId] : null;
 }
Пример #4
0
 /**
  * Prepare data before save
  *
  * @return void
  */
 public function beforeSave()
 {
     $value = $this->getValue();
     $value = $this->_catalogInventoryMinsaleqty->makeStorableArrayFieldValue($value);
     $this->setValue($value);
 }
Пример #5
0
 /**
  * @param null|string|bool|int|\Magento\Store\Model\Store $store
  * @param int $customerGroupId
  * @return float
  */
 public function getMinSaleQty($store = null, $customerGroupId = null)
 {
     return (double) $this->minsaleqtyHelper->getConfigValue($customerGroupId, $store);
 }