Skip to content

Commit 0b01926

Browse files
committed
#12804: [GitHub] Performance: Improve attribute deletion to take advantage of indexes
1 parent 11da0ea commit 0b01926

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/AttributeTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66
namespace Magento\Catalog\Model\ResourceModel;
77

8+
use Magento\Catalog\Api\Data\ProductInterface;
89
use Magento\Catalog\Api\ProductRepositoryInterface;
10+
use Magento\Framework\EntityManager\MetadataPool;
911

1012
/**
1113
* Test class for Catalog attribute resource model.
@@ -24,6 +26,11 @@ class AttributeTest extends \PHPUnit\Framework\TestCase
2426
*/
2527
protected $productResource;
2628

29+
/**
30+
* @var MetadataPool
31+
*/
32+
private $metadataPool;
33+
2734
/**
2835
* @var \Magento\Framework\ObjectManagerInterface
2936
*/
@@ -38,6 +45,7 @@ protected function setUp()
3845
$this->productResource = $this->objectManager->get(
3946
\Magento\Catalog\Model\ResourceModel\Product::class
4047
);
48+
$this->metadataPool = $this->objectManager->get(MetadataPool::class);
4149
}
4250

4351
/**
@@ -125,11 +133,12 @@ private function getEavEntityAttributeRow($entityTypeId, $attributeSetId, $attri
125133
*/
126134
private function getProductAttributeValues($attributeId, $productId, $table)
127135
{
136+
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
128137
$connection = $this->productResource->getConnection();
129138
$select = $connection->select()
130139
->from($this->productResource->getTable($table))
131140
->where('attribute_id=?', $attributeId)
132-
->where('entity_id=?', $productId);
141+
->where($linkField . '=?', $productId);
133142

134143
return $connection->fetchAll($select);
135144
}

0 commit comments

Comments
 (0)