/** * Creates a collection item that represents a tax rule for the tax rules grid. * * @param TaxRuleInterface $taxRule Input data for creating the item. * @return \Magento\Framework\Object Collection item that represents a tax rule */ protected function createTaxRuleCollectionItem(TaxRuleInterface $taxRule) { $collectionItem = new \Magento\Framework\Object(); $collectionItem->setTaxCalculationRuleId($taxRule->getId()); $collectionItem->setCode($taxRule->getCode()); /* should cast to string so that some optional fields won't be null on the collection grid pages */ $collectionItem->setPriority((string) $taxRule->getPriority()); $collectionItem->setPosition((string) $taxRule->getPosition()); $collectionItem->setCalculateSubtotal($taxRule->getCalculateSubtotal() ? '1' : '0'); $collectionItem->setCustomerTaxClasses($taxRule->getCustomerTaxClassIds()); $collectionItem->setProductTaxClasses($taxRule->getProductTaxClassIds()); $collectionItem->setTaxRates($taxRule->getTaxRateIds()); return $collectionItem; }
/** * {@inheritdoc} */ public function delete(TaxRuleInterface $rule) { $ruleId = $rule->getId(); $this->resource->delete($rule); $this->taxRuleRegistry->removeTaxRule($ruleId); return true; }