/**
  * {@inheritdoc}
  */
 public function getData()
 {
     if (isset($this->loadedData)) {
         return $this->loadedData;
     }
     $items = $this->collection->getItems();
     /** @var Rule $rule */
     foreach ($items as $rule) {
         $rule->load($rule->getId());
         $rule->setDiscountAmount($rule->getDiscountAmount() * 1);
         $rule->setDiscountQty($rule->getDiscountQty() * 1);
         $this->loadedData[$rule->getId()] = $rule->getData();
     }
     return $this->loadedData;
 }
Exemplo n.º 2
0
 /**
  * @param string $action
  * @dataProvider dataProviderActions
  */
 public function testProcessShippingAmountActions($action)
 {
     $discountAmount = 50;
     $ruleMock = $this->getMockBuilder('Magento\\SalesRule\\Model\\Rule')->disableOriginalConstructor()->setMethods(['getApplyToShipping', 'getSimpleAction', 'getDiscountAmount'])->getMock();
     $ruleMock->expects($this->any())->method('getApplyToShipping')->willReturn(true);
     $ruleMock->expects($this->any())->method('getDiscountAmount')->willReturn($discountAmount);
     $ruleMock->expects($this->any())->method('getSimpleAction')->willReturn($action);
     $iterator = new \ArrayIterator([$ruleMock]);
     $this->ruleCollection->expects($this->any())->method('getIterator')->willReturn($iterator);
     $this->utility->expects($this->any())->method('canProcessRule')->willReturn(true);
     $this->model->init($this->model->getWebsiteId(), $this->model->getCustomerGroupId(), $this->model->getCouponCode());
     $this->assertInstanceOf('Magento\\SalesRule\\Model\\Validator', $this->model->processShippingAmount($this->getAddressMock(5)));
 }
Exemplo n.º 3
0
 /**
  * Add websites for load
  *
  * @return $this
  */
 public function _initSelect()
 {
     parent::_initSelect();
     $this->addWebsitesToResult();
     return $this;
 }
Exemplo n.º 4
0
 /**
  * Helper function that adds a FilterGroup to the collection.
  *
  * @param \Magento\Framework\Api\Search\FilterGroup $filterGroup
  * @param Collection $collection
  * @return void
  */
 protected function addFilterGroupToCollection(\Magento\Framework\Api\Search\FilterGroup $filterGroup, Collection $collection)
 {
     $fields = [];
     $conditions = [];
     foreach ($filterGroup->getFilters() as $filter) {
         $condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
         $fields[] = $filter->getField();
         $conditions[] = [$condition => $filter->getValue()];
     }
     if ($fields) {
         $collection->addFieldToFilter($fields, $conditions);
     }
 }