6 declare(strict_types=1);
27 private $metadataPool;
37 private $connectionName;
49 $connectionName =
'indexer' 52 $this->metadataPool = $metadataPool;
54 $this->connectionName = $connectionName;
69 $attributeTable =
$attribute->getBackend()->getTable();
70 $connection = $this->resource->getConnection($this->connectionName);
71 $joinType = $attributeValue !==
null ?
'join' :
'joinLeft';
72 $productIdField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
77 [
$alias => $attributeTable],
78 "{$alias}.{$productIdField} = e.{$productIdField} AND {$alias}.attribute_id = {$attributeId}" .
79 " AND {$alias}.store_id = 0",
82 $whereExpression =
new Expression(
"{$alias}.value");
88 [$dAlias => $attributeTable],
89 "{$dAlias}.{$productIdField} = e.{$productIdField} AND {$dAlias}.attribute_id = {$attributeId}" .
90 " AND {$dAlias}.store_id = 0",
94 [$sAlias => $attributeTable],
95 "{$sAlias}.{$productIdField} = e.{$productIdField} AND {$sAlias}.attribute_id = {$attributeId}" .
96 " AND {$sAlias}.store_id = cwd.default_store_id",
100 $connection->getIfNullSql(
"{$sAlias}.value_id", -1) .
' > 0',
106 if ($attributeValue !==
null) {
107 $select->where(
"{$whereExpression} = ?", $attributeValue);
110 return $whereExpression;
process(Select $select, $attributeCode, $attributeValue=null)
__construct(\Magento\Eav\Model\Config $eavConfig, \Magento\Framework\EntityManager\MetadataPool $metadataPool, \Magento\Framework\App\ResourceConnection $resource, $connectionName='indexer')