Skip to content

Commit

Permalink
MAGETWO-52717: [GitHub] Configurable product disabling lowest price a…
Browse files Browse the repository at this point in the history
…ssociated product still shows its price #4419

-- fix integration tests
  • Loading branch information
vnayda committed Oct 6, 2016
1 parent 0027ad7 commit a86ea1c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ public function build($productId)
[]
)->joinInner(
[BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS => $productTable],
sprintf('%s.%s = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS, $linkField),
[$linkField]
sprintf('%s.entity_id = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
['entity_id']
)->joinInner(
['t' => $this->resource->getTableName('catalog_product_index_price')],
sprintf('t.entity_id = %s.%s', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS, $linkField),
sprintf('t.entity_id = %s.entity_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
[]
)->where("parent.{$linkField} = ?", $productId)
)->where('parent.entity_id = ?', $productId)
->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId())
->where('t.customer_group_id = ?', $this->customerSession->getCustomerGroupId())
->order('t.min_price ' . Select::SQL_ASC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ public function build($productId)
[]
)->joinInner(
[BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS => $productTable],
sprintf('%s.%s = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS, $linkField),
[$linkField]
sprintf('%s.entity_id = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS, $linkField),
['entity_id']
)->joinInner(
['t' => $priceAttribute->getBackendTable()],
sprintf('t.%s = %s.%1$s', $linkField, BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
[]
)->where("parent.{$linkField} = ?", $productId)
)->where('parent.entity_id = ?', $productId)
->where('t.attribute_id = ?', $priceAttribute->getAttributeId())
->where('t.value IS NOT NULL')
->order('t.value ' . Select::SQL_ASC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public function build($productId)
[]
)->joinInner(
[BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS => $productTable],
sprintf('%s.%s = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS, $linkField),
[$linkField]
sprintf('%s.entity_id = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
['entity_id']
)->joinInner(
['t' => $specialPriceAttribute->getBackendTable()],
sprintf('t.%s = %s.%1$s', $linkField, BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
Expand All @@ -126,7 +126,7 @@ public function build($productId)
$specialPriceToDate->getAttributeId()
),
''
)->where("parent.{$linkField} = ?", $productId)
)->where('parent.entity_id = ?', $productId)
->where('t.attribute_id = ?', $specialPriceAttribute->getAttributeId())
->where('t.value IS NOT NULL')
->where(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public function build($productId)
[]
)->joinInner(
[BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS => $productTable],
sprintf('%s.%s = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS, $linkField),
[$linkField]
sprintf('%s.entity_id = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
['entity_id']
)->joinInner(
['t' => $this->resource->getTableName('catalog_product_entity_tier_price')],
sprintf('t.%s = %s.%1$s', $linkField, BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
[]
)->where("parent.{$linkField} = ?", $productId)
)->where('parent.entity_id = ?', $productId)
->where('t.all_groups = 1 OR customer_group_id = ?', $this->customerSession->getCustomerGroupId())
->where('t.qty = ?', 1)
->order('t.value ' . Select::SQL_ASC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function process(Select $select)
/** @var Select $select */
$select->join(
['stock' => $stockStatusTable],
sprintf('stock.product_id = %s.%s', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS, $linkField),
sprintf('stock.product_id = %s.entity_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
[]
)
->where('stock.stock_status = ?', Stock::STOCK_IN_STOCK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ public function build($productId)
[]
)->joinInner(
[BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS => $productTable],
sprintf('%s.%s = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS, $linkField),
[$linkField]
sprintf('%s.entity_id = link.child_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
['entity_id']
)->joinInner(
['t' => $this->resource->getTableName('catalogrule_product_price')],
sprintf('t.product_id = %s.%s', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS, $linkField),
[]
)->where("parent.{$linkField} = ?", $productId)
)->where('parent.entity_id = ?', $productId)
->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId())
->where('t.customer_group_id = ?', $this->customerSession->getCustomerGroupId())
->where('t.rule_date = ?', $currentDate)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\TestFramework\Helper\Bootstrap;

$objectManager = Bootstrap::getObjectManager();
/** @var ProductRepositoryInterface $productRepository */
$productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class);

foreach (['sku_10', 'sku_20', 'configurable_product_with_two_simple'] as $sku) {
try {
$product = $productRepository->get($sku, false, null, true);
$productRepository->delete($product);
} catch (NoSuchEntityException $e) {
//Product already removed
}
}

require __DIR__ . '/configurable_attribute_rollback.php';

0 comments on commit a86ea1c

Please sign in to comment.