Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Rule.php
Go to the documentation of this file.
1 <?php
7 
14 {
20  protected function _construct()
21  {
22  $this->_init('tax_calculation_rule', 'tax_calculation_rule_id');
23  }
24 
30  protected function _initUniqueFields()
31  {
32  $this->_uniqueFields = [['field' => ['code'], 'title' => __('Code')]];
33  return $this;
34  }
35 
44  public function fetchRuleCodes($rateId, $customerTaxClassIds, $productTaxClassIds)
45  {
46  $connection = $this->getConnection();
47  $select = $connection->select()
48  ->from(['main' => $this->getTable('tax_calculation')], null)
49  ->joinLeft(
50  ['d' => $this->getTable('tax_calculation_rule')],
51  'd.tax_calculation_rule_id = main.tax_calculation_rule_id',
52  ['d.code']
53  )
54  ->where('main.tax_calculation_rate_id in (?)', $rateId)
55  ->where('main.customer_tax_class_id in (?)', $customerTaxClassIds)
56  ->where('main.product_tax_class_id in (?)', $productTaxClassIds)
57  ->distinct(true);
58 
59  return $connection->fetchCol($select);
60  }
61 }
__()
Definition: __.php:13
fetchRuleCodes($rateId, $customerTaxClassIds, $productTaxClassIds)
Definition: Rule.php:44
$connection
Definition: bulk.php:13