Skip to content

Commit f93d674

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-61164' into 2.1-develop-pr36
2 parents d883017 + c0b9a76 commit f93d674

File tree

6 files changed

+76
-27
lines changed

6 files changed

+76
-27
lines changed

app/code/Magento/ConfigurableProduct/Model/ResourceModel/Indexer/Stock/Configurable.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,25 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
2929
$connection = $this->getConnection();
3030
$idxTable = $usePrimaryTable ? $this->getMainTable() : $this->getIdxTable();
3131
$select = parent::_getStockStatusSelect($entityIds, $usePrimaryTable);
32+
$linkField = $metadata->getLinkField();
3233
$select->reset(
3334
\Magento\Framework\DB\Select::COLUMNS
3435
)->columns(
3536
['e.entity_id', 'cis.website_id', 'cis.stock_id']
3637
)->joinLeft(
3738
['l' => $this->getTable('catalog_product_super_link')],
38-
'l.parent_id = e.' . $metadata->getLinkField(),
39+
'l.parent_id = e.' . $linkField,
3940
[]
4041
)->join(
4142
['le' => $this->getTable('catalog_product_entity')],
4243
'le.entity_id = l.product_id',
4344
[]
45+
)->joinInner(
46+
['cpei' => $this->getTable('catalog_product_entity_int')],
47+
'le.' . $linkField . ' = cpei.' . $linkField
48+
. ' AND cpei.attribute_id = ' . $this->_getAttribute('status')->getId()
49+
. ' AND cpei.value = ' . ProductStatus::STATUS_ENABLED,
50+
[]
4451
)->joinLeft(
4552
['i' => $idxTable],
4653
'i.product_id = l.product_id AND cis.website_id = i.website_id AND cis.stock_id = i.stock_id',

dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ public function testBoolFilterWithNestedRangeInNegativeBoolFilter()
378378
*
379379
* @magentoConfigFixture current_store catalog/search/engine mysql
380380
* @dataProvider advancedSearchDataProvider
381+
* @param string $nameQuery
382+
* @param string $descriptionQuery
383+
* @param array $rangeFilter
384+
* @param int $expectedRecordsCount
381385
* @return void
382386
*/
383387
public function testSimpleAdvancedSearch(
@@ -446,6 +450,38 @@ public function testCustomFilterableAttribute()
446450
$this->assertEquals(1, $queryResponse->count());
447451
}
448452

453+
/**
454+
* @magentoDataFixture Magento/Framework/Search/_files/product_configurable_with_disabled_child.php
455+
* @magentoConfigFixture current_store catalog/search/engine mysql
456+
* @return void
457+
*/
458+
public function testAdvancedSearchCompositeProductWithDisabledChild()
459+
{
460+
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
461+
$attribute = $this->objectManager->get(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
462+
->loadByCode(\Magento\Catalog\Model\Product::ENTITY, 'test_configurable_searchable');
463+
/** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection $selectOptions */
464+
$selectOptions = $this->objectManager
465+
->create(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection::class)
466+
->setAttributeFilter($attribute->getId());
467+
468+
$firstOption = $selectOptions->getFirstItem();
469+
$firstOptionId = $firstOption->getId();
470+
$this->requestBuilder->bind('test_configurable_searchable', $firstOptionId);
471+
$this->requestBuilder->setRequestName('filter_out_of_stock_child');
472+
473+
$queryResponse = $this->executeQuery();
474+
$this->assertEquals(0, $queryResponse->count());
475+
476+
$secondOption = $selectOptions->getLastItem();
477+
$secondOptionId = $secondOption->getId();
478+
$this->requestBuilder->bind('test_configurable_searchable', $secondOptionId);
479+
$this->requestBuilder->setRequestName('filter_out_of_stock_child');
480+
481+
$queryResponse = $this->executeQuery();
482+
$this->assertEquals(0, $queryResponse->count());
483+
}
484+
449485
/**
450486
* Advanced search request using date product attribute.
451487
*

dev/tests/integration/testsuite/Magento/Framework/Search/_files/product_configurable.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,29 +109,6 @@
109109

110110
$product->setExtensionAttributes($extensionConfigurableAttributes);
111111

112-
// Remove any previously created product with the same id.
113-
/** @var \Magento\Framework\Registry $registry */
114-
$registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
115-
$registry->unregister('isSecureArea');
116-
$registry->register('isSecureArea', true);
117-
118-
try {
119-
$productToDelete = $productRepository->getById(10001);
120-
$productRepository->delete($productToDelete);
121-
122-
/** @var \Magento\Quote\Model\ResourceModel\Quote\Item $itemResource */
123-
$itemResource = Bootstrap::getObjectManager()->get(\Magento\Quote\Model\ResourceModel\Quote\Item::class);
124-
$itemResource->getConnection()->delete(
125-
$itemResource->getMainTable(),
126-
'product_id = ' . $productToDelete->getId()
127-
);
128-
} catch (\Exception $e) {
129-
// Nothing to remove
130-
}
131-
132-
$registry->unregister('isSecureArea');
133-
$registry->register('isSecureArea', false);
134-
135112
$product->setTypeId(Configurable::TYPE_CODE)
136113
->setId(10001)
137114
->setAttributeSetId($attributeSetId)

dev/tests/integration/testsuite/Magento/Framework/Search/_files/product_configurable_rollback.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,27 @@
33
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
use Magento\TestFramework\Helper\Bootstrap;
76

8-
$objectManager = Bootstrap::getObjectManager();
7+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8+
99
/** @var \Magento\Framework\Registry $registry */
1010
$registry = $objectManager->get(\Magento\Framework\Registry::class);
11+
1112
$registry->unregister('isSecureArea');
1213
$registry->register('isSecureArea', true);
14+
1315
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
14-
$productRepository = Bootstrap::getObjectManager()
16+
$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
1517
->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
1618

1719
foreach (['simple_10010', 'simple_10020', 'configurable_searchable'] as $sku) {
1820
try {
1921
$product = $productRepository->get($sku, false, null, true);
22+
2023
$stockStatus = $objectManager->create(\Magento\CatalogInventory\Model\Stock\Status::class);
2124
$stockStatus->load($product->getEntityId(), 'product_id');
2225
$stockStatus->delete();
26+
2327
$productRepository->delete($product);
2428
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
2529
//Product already removed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Catalog\Api\ProductRepositoryInterface;
8+
use Magento\TestFramework\Helper\Bootstrap;
9+
10+
require __DIR__ . '/product_configurable.php';
11+
12+
/** @var ProductRepositoryInterface $productRepository */
13+
$productRepository = Bootstrap::getObjectManager()
14+
->create(ProductRepositoryInterface::class);
15+
16+
$product = $productRepository->get('simple_10020');
17+
$product->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED);
18+
$productRepository->save($product);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
require __DIR__ . '/product_configurable_rollback.php';

0 commit comments

Comments
 (0)