Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function build($productId)
public function build($productId, $limit = 1)
{
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$productTable = $this->resource->getTableName('catalog_product_entity');
Expand All @@ -86,7 +86,7 @@ public function build($productId)
->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId())
->where('t.customer_group_id = ?', $this->customerSession->getCustomerGroupId())
->order('t.min_price ' . Select::SQL_ASC)
->limit(1);
->limit($limit);
$priceSelect = $this->baseSelectProcessor->process($priceSelect);

return [$priceSelect];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function build($productId)
public function build($productId, $limit = 1)
{
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$priceAttribute = $this->eavConfig->getAttribute(Product::ENTITY, 'price');
Expand All @@ -95,9 +95,8 @@ public function build($productId)
->where('t.attribute_id = ?', $priceAttribute->getAttributeId())
->where('t.value IS NOT NULL')
->order('t.value ' . Select::SQL_ASC)
->limit(1);
->limit($limit);
$priceSelect = $this->baseSelectProcessor->process($priceSelect);

$priceSelectDefault = clone $priceSelect;
$priceSelectDefault->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
$select[] = $priceSelectDefault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function build($productId)
public function build($productId, $limit = 1)
{
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$connection = $this->resource->getConnection();
Expand Down Expand Up @@ -139,9 +139,8 @@ public function build($productId)
'special_to.value IS NULL OR ' . $connection->getDatePartSql('special_to.value') .' >= ?',
$currentDate
)->order('t.value ' . Select::SQL_ASC)
->limit(1);
->limit($limit);
$specialPrice = $this->baseSelectProcessor->process($specialPrice);

$specialPriceDefault = clone $specialPrice;
$specialPriceDefault->where('t.store_id = ?', Store::DEFAULT_STORE_ID);
$select[] = $specialPriceDefault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function build($productId)
public function build($productId, $limit = 1)
{
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$productTable = $this->resource->getTableName('catalog_product_entity');
Expand All @@ -97,9 +97,8 @@ public function build($productId)
->where('t.all_groups = 1 OR customer_group_id = ?', $this->customerSession->getCustomerGroupId())
->where('t.qty = ?', 1)
->order('t.value ' . Select::SQL_ASC)
->limit(1);
->limit($limit);
$priceSelect = $this->baseSelectProcessor->process($priceSelect);

$priceSelectDefault = clone $priceSelect;
$priceSelectDefault->where('t.website_id = ?', self::DEFAULT_WEBSITE_ID);
$select[] = $priceSelectDefault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public function __construct($linkedProductSelectBuilder)
/**
* {@inheritdoc}
*/
public function build($productId)
public function build($productId, $limit = 1)
{
$select = [];
foreach ($this->linkedProductSelectBuilder as $productSelectBuilder) {
$select = array_merge($select, $productSelectBuilder->build($productId));
$select = array_merge($select, $productSelectBuilder->build($productId, $limit));
}

return $select;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ interface LinkedProductSelectBuilderInterface
{
/**
* @param int $productId
* @param int $limit
* @return \Magento\Framework\DB\Select[]
*/
public function build($productId);
public function build($productId, $limit = 1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
public function build($productId)
public function build($productId, $limit = 1)
{
$timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
$currentDate = $this->dateTime->formatDate($timestamp, false);
Expand All @@ -105,7 +105,7 @@ public function build($productId)
->where('t.customer_group_id = ?', $this->customerSession->getCustomerGroupId())
->where('t.rule_date = ?', $currentDate)
->order('t.rule_price ' . Select::SQL_ASC)
->limit(1);
->limit($limit);
$priceSelect = $this->baseSelectProcessor->process($priceSelect);

return [$priceSelect];
Expand Down