31 private $activeTableSwitcher;
36 private $tableSwapper;
48 TableSwapper $tableSwapper =
null 50 $this->dateFormat = $dateFormat;
52 $this->activeTableSwitcher = $activeTableSwitcher;
53 $this->tableSwapper = $tableSwapper ??
65 public function execute(array $priceData, $useAdditionalTable =
false)
67 if (empty($priceData)) {
72 $indexTable = $this->resource->getTableName(
'catalogrule_product_price');
73 if ($useAdditionalTable) {
74 $indexTable = $this->resource->getTableName(
75 $this->tableSwapper->getWorkingTableName(
'catalogrule_product_price')
82 foreach ($priceData as $key =>
$data) {
84 $priceData[$key][
'rule_date'] = $this->dateFormat->formatDate(
$data[
'rule_date'],
false);
85 $priceData[$key][
'latest_start_date'] = $this->dateFormat->formatDate(
86 $data[
'latest_start_date'],
89 $priceData[$key][
'earliest_end_date'] = $this->dateFormat->formatDate(
90 $data[
'earliest_end_date'],
94 $connection->insertOnDuplicate($indexTable, $priceData);
__construct(\Magento\Framework\Stdlib\DateTime $dateFormat, \Magento\Framework\App\ResourceConnection $resource, ActiveTableSwitcher $activeTableSwitcher, TableSwapper $tableSwapper=null)
execute(array $priceData, $useAdditionalTable=false)