Skip to content

Commit 0b8581c

Browse files
Added an optional limit arg to build functions of LinkedProductSelectBuilders and a limit of PHP_INT_MAX to ConfigurableOptionsProvider
1 parent 813fad8 commit 0b8581c

7 files changed

+14
-16
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/LinkedProductSelectBuilderByIndexPrice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct(
6363
/**
6464
* {@inheritdoc}
6565
*/
66-
public function build($productId)
66+
public function build($productId, $limit = 1)
6767
{
6868
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
6969
$productTable = $this->resource->getTableName('catalog_product_entity');
@@ -86,7 +86,7 @@ public function build($productId)
8686
->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId())
8787
->where('t.customer_group_id = ?', $this->customerSession->getCustomerGroupId())
8888
->order('t.min_price ' . Select::SQL_ASC)
89-
->limit(1);
89+
->limit($limit)];
9090
$priceSelect = $this->baseSelectProcessor->process($priceSelect);
9191

9292
return [$priceSelect];

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByBasePrice.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct(
7171
/**
7272
* {@inheritdoc}
7373
*/
74-
public function build($productId)
74+
public function build($productId, $limit = 1)
7575
{
7676
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
7777
$priceAttribute = $this->eavConfig->getAttribute(Product::ENTITY, 'price');
@@ -95,9 +95,8 @@ public function build($productId)
9595
->where('t.attribute_id = ?', $priceAttribute->getAttributeId())
9696
->where('t.value IS NOT NULL')
9797
->order('t.value ' . Select::SQL_ASC)
98-
->limit(1);
98+
->limit($limit);
9999
$priceSelect = $this->baseSelectProcessor->process($priceSelect);
100-
101100
$priceSelectDefault = clone $priceSelect;
102101
$priceSelectDefault->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
103102
$select[] = $priceSelectDefault;

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderBySpecialPrice.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function __construct(
9090
/**
9191
* {@inheritdoc}
9292
*/
93-
public function build($productId)
93+
public function build($productId, $limit = 1)
9494
{
9595
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
9696
$connection = $this->resource->getConnection();
@@ -139,9 +139,8 @@ public function build($productId)
139139
'special_to.value IS NULL OR ' . $connection->getDatePartSql('special_to.value') .' >= ?',
140140
$currentDate
141141
)->order('t.value ' . Select::SQL_ASC)
142-
->limit(1);
142+
->limit($limit);
143143
$specialPrice = $this->baseSelectProcessor->process($specialPrice);
144-
145144
$specialPriceDefault = clone $specialPrice;
146145
$specialPriceDefault->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
147146
$select[] = $specialPriceDefault;

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderByTierPrice.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function __construct(
7474
/**
7575
* {@inheritdoc}
7676
*/
77-
public function build($productId)
77+
public function build($productId, $limit = 1)
7878
{
7979
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
8080
$productTable = $this->resource->getTableName('catalog_product_entity');
@@ -97,9 +97,8 @@ public function build($productId)
9797
->where('t.all_groups = 1 OR customer_group_id = ?', $this->customerSession->getCustomerGroupId())
9898
->where('t.qty = ?', 1)
9999
->order('t.value ' . Select::SQL_ASC)
100-
->limit(1);
100+
->limit($limit);
101101
$priceSelect = $this->baseSelectProcessor->process($priceSelect);
102-
103102
$priceSelectDefault = clone $priceSelect;
104103
$priceSelectDefault->where('t.website_id = ?', self::DEFAULT_WEBSITE_ID);
105104
$select[] = $priceSelectDefault;

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderComposite.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ public function __construct($linkedProductSelectBuilder)
2424
/**
2525
* {@inheritdoc}
2626
*/
27-
public function build($productId)
27+
public function build($productId, $limit = 1)
2828
{
2929
$select = [];
3030
foreach ($this->linkedProductSelectBuilder as $productSelectBuilder) {
31-
$select = array_merge($select, $productSelectBuilder->build($productId));
31+
$select = array_merge($select, $productSelectBuilder->build($productId, $limit));
3232
}
3333

3434
return $select;

app/code/Magento/Catalog/Model/ResourceModel/Product/LinkedProductSelectBuilderInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ interface LinkedProductSelectBuilderInterface
1212
{
1313
/**
1414
* @param int $productId
15+
* @param int $limit
1516
* @return \Magento\Framework\DB\Select[]
1617
*/
17-
public function build($productId);
18+
public function build($productId, $limit = 1);
1819
}

app/code/Magento/CatalogRule/Model/ResourceModel/Product/LinkedProductSelectBuilderByCatalogRulePrice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function __construct(
7979
/**
8080
* {@inheritdoc}
8181
*/
82-
public function build($productId)
82+
public function build($productId, $limit = 1)
8383
{
8484
$timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
8585
$currentDate = $this->dateTime->formatDate($timestamp, false);
@@ -105,7 +105,7 @@ public function build($productId)
105105
->where('t.customer_group_id = ?', $this->customerSession->getCustomerGroupId())
106106
->where('t.rule_date = ?', $currentDate)
107107
->order('t.rule_price ' . Select::SQL_ASC)
108-
->limit(1);
108+
->limit($limit)];
109109
$priceSelect = $this->baseSelectProcessor->process($priceSelect);
110110

111111
return [$priceSelect];

0 commit comments

Comments
 (0)