Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #357 from afirlejczyk/bugfix/tax-class-fetcher
Browse files Browse the repository at this point in the history
Improved Customer and Product Tax Class fetcher for Tax Rules #354
  • Loading branch information
afirlejczyk authored Nov 4, 2020
2 parents c185fe5 + 551c4c4 commit 089e242
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
...


## [1.25.0] (2020.11.04)

### Fixed
- Improved Customer and Product Tax Class fetcher for Tax Rules ([#354](https://github.com/DivanteLtd/magento2-vsbridge-indexer/issues/353))

## [1.24.0]

## [1.23.0] (2020.11.03)

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,19 @@ public function addData(array $indexData, $storeId)

foreach ($taxClasses as $data) {
$ruleId = $data['tax_calculation_rule_id'];
$indexData[$ruleId]['customer_tax_class_ids'][] = (int)$data['customer_tax_class_id'];
$indexData[$ruleId]['product_tax_class_ids'][] = (int)$data['product_tax_class_id'];
$indexData[$ruleId]['customer_tax_class_ids'] = $this->explodeAsInt($data['customer_tax_class_ids']);
$indexData[$ruleId]['product_tax_class_ids'] = $this->explodeAsInt($data['product_tax_class_ids']);
}

return $indexData;
}

/**
* @param string $concatIds
* @return array
*/
protected function explodeAsInt(string $concatIds) : array
{
return array_map('intval', explode(',', $concatIds));
}
}
9 changes: 4 additions & 5 deletions src/module-vsbridge-indexer-tax/ResourceModel/TaxClasses.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ public function loadTaxClasses(array $ruleIds)
$this->resource->getTableName('tax_calculation'),
[
'tax_calculation_rule_id',
'customer_tax_class_id',
'product_tax_class_id',
'customer_tax_class_ids' => new \Zend_Db_Expr('GROUP_CONCAT(DISTINCT(`customer_tax_class_id`))'),
'product_tax_class_ids' => new \Zend_Db_Expr('GROUP_CONCAT(DISTINCT(`product_tax_class_id`))'),
]
)->where('tax_calculation_rule_id IN (?)', $ruleIds);

$select->distinct(true);
)->where('tax_calculation_rule_id IN (?)', $ruleIds
)->group('tax_calculation_rule_id');

return $this->getConnection()->fetchAssoc($select);
}
Expand Down

0 comments on commit 089e242

Please sign in to comment.