31 private $storeManager;
36 private $metadataPool;
41 private $activeTableSwitcher;
46 private $tableSwapper;
62 TableSwapper $tableSwapper =
null 66 $this->metadataPool = $metadataPool;
68 $this->activeTableSwitcher = $activeTableSwitcher;
69 $this->tableSwapper = $tableSwapper ??
84 $useAdditionalTable =
false 87 $indexTable = $this->resource->getTableName(
'catalogrule_product');
88 if ($useAdditionalTable) {
89 $indexTable = $this->resource->getTableName(
90 $this->tableSwapper->getWorkingTableName(
'catalogrule_product')
105 [
'rp' => $indexTable]
107 [
'rp.website_id',
'rp.customer_group_id',
'rp.product_id',
'rp.sort_order',
'rp.rule_id']
118 $priceTable = $priceAttr->getBackend()->getTable();
119 $attributeId = $priceAttr->getId();
121 $linkField = $this->metadataPool
122 ->getMetadata(\
Magento\Catalog\Api\
Data\ProductInterface::class)
125 [
'e' => $this->resource->getTableName(
'catalog_product_entity')],
126 sprintf(
'e.entity_id = rp.product_id'),
129 $joinCondition =
'%1$s.' . $linkField .
'=e.' . $linkField .
' AND (%1$s.attribute_id=' 131 .
') and %1$s.store_id=%2$s';
134 [
'pp_default' => $priceTable],
140 $defaultGroup =
$website->getDefaultGroup();
141 if ($defaultGroup instanceof \
Magento\
Store\Model\Group) {
142 $storeId = $defaultGroup->getDefaultStoreId();
148 [
'product_website' => $this->resource->getTableName(
'catalog_product_website')],
149 'product_website.product_id=rp.product_id ' 150 .
'AND product_website.website_id = rp.website_id ' 151 .
'AND product_website.website_id=' 158 [$tableAlias => $priceTable],
159 sprintf($joinCondition, $tableAlias,
$storeId),
163 'default_price' =>
$connection->getIfNullSql($tableAlias .
'.value',
'pp_default.value'),
__construct(\Magento\Framework\App\ResourceConnection $resource, \Magento\Eav\Model\Config $eavConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\EntityManager\MetadataPool $metadataPool, ActiveTableSwitcher $activeTableSwitcher, TableSwapper $tableSwapper=null)
build( $websiteId, \Magento\Catalog\Model\Product $product=null, $useAdditionalTable=false)