collection = $collectionFactory->create(); $this->coreRegistry = $registry; $this->metadataValueProvider = $metadataValueProvider; $meta = array_replace_recursive($this->getMetadataValues(), $meta); parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); } /** * Get metadata values * * @return array */ protected function getMetadataValues() { $rule = $this->coreRegistry->registry(\Magento\SalesRule\Model\RegistryConstants::CURRENT_SALES_RULE); return $this->metadataValueProvider->getMetadataValues($rule); } /** * {@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; } }