From b0dd012b75166bd718a351e7ca76b00ccd455614 Mon Sep 17 00:00:00 2001 From: Oleksandr Radchenko Date: Tue, 11 Apr 2017 16:18:48 +0300 Subject: [PATCH 01/11] MAGETWO-67291: [Performance] Layered Navigation built for Non Anchored categories --- .../Aggregation/AggregationResolver.php | 18 ++- .../Checker/Query/AdvancedSearch.php | 44 ++++++ .../Aggregation/Checker/Query/CatalogView.php | 148 ++++++++++++++++++ .../Aggregation/RequestCheckerComposite.php | 76 +++++++++ .../Aggregation/RequestCheckerInterface.php | 24 +++ .../Aggregation/AggregationResolverTest.php | 16 +- app/code/Magento/CatalogSearch/etc/di.xml | 21 ++- 7 files changed, 343 insertions(+), 4 deletions(-) create mode 100644 app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php create mode 100644 app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php create mode 100644 app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php create mode 100644 app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerInterface.php diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php index b880f8fb8afa4..1feae40291f71 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php @@ -36,11 +36,16 @@ class AggregationResolver implements AggregationResolverInterface */ private $config; + /** + * @var RequestCheckerInterface + */ + private $requestChecker; + /** * @var AttributeCollection */ private $attributeCollection; - + /** * AggregationResolver constructor * @@ -48,6 +53,7 @@ class AggregationResolver implements AggregationResolverInterface * @param ProductAttributeRepositoryInterface $productAttributeRepository * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param Config $config + * @param RequestCheckerInterface $aggregationChecker * @param AttributeCollection $attributeCollection [optional] */ public function __construct( @@ -55,6 +61,7 @@ public function __construct( ProductAttributeRepositoryInterface $productAttributeRepository, SearchCriteriaBuilder $searchCriteriaBuilder, Config $config, + RequestCheckerInterface $aggregationChecker = null, AttributeCollection $attributeCollection = null ) { $this->attributeSetFinder = $attributeSetFinder; @@ -63,6 +70,8 @@ public function __construct( $this->config = $config; $this->attributeCollection = $attributeCollection ?: \Magento\Framework\App\ObjectManager::getInstance()->get(AttributeCollection::class); + $this->requestChecker = $aggregationChecker ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(RequestCheckerInterface::class); } /** @@ -70,6 +79,10 @@ public function __construct( */ public function resolve(RequestInterface $request, array $documentIds) { + if (!$this->requestChecker->isApplicable($request)) { + return []; + } + $data = $this->config->get($request->getName()); $bucketKeys = isset($data['aggregations']) ? array_keys($data['aggregations']) : []; @@ -79,7 +92,8 @@ public function resolve(RequestInterface $request, array $documentIds) $request->getAggregation(), function ($bucket) use ($attributeCodes, $bucketKeys) { /** @var BucketInterface $bucket */ - return in_array($bucket->getField(), $attributeCodes) || in_array($bucket->getName(), $bucketKeys); + return in_array($bucket->getField(), $attributeCodes, true) || + in_array($bucket->getName(), $bucketKeys, true); } ); return array_values($resolvedAggregation); diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php new file mode 100644 index 0000000000000..79c8e4bd6c3b9 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php @@ -0,0 +1,44 @@ +name = $name; + } + + /** + * {@inheritdoc} + */ + public function isApplicable(RequestInterface $request) + { + $result = true; + // It's no need to render LN filters for advanced search + if ($request->getName() === $this->name) { + $result = false; + } + + return $result; + } +} diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php new file mode 100644 index 0000000000000..0cffe1b206756 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php @@ -0,0 +1,148 @@ +categoryRepository = $categoryRepository; + $this->storeManager = $storeManager; + $this->name = $name; + } + + /** + * {@inheritdoc} + */ + public function isApplicable(RequestInterface $request) + { + $result = true; + if ($request->getName() === $this->name) { + $result = $this->hasAnchorCategory($request); + } + + return $result; + } + + /** + * Check whether category is anchor. + * + * Proceeds with request and check whether at least one of categories is anchor. + * + * @param RequestInterface $request + * @return bool + */ + private function hasAnchorCategory(RequestInterface $request) + { + $queryType = $request->getQuery()->getType(); + $result = false; + + if ($queryType === QueryInterface::TYPE_BOOL) { + $categories = $this->getCategoriesFromQuery($request->getQuery()); + + /** @var \Magento\Catalog\Api\Data\CategoryInterface $category */ + foreach ($categories as $category) { + // It's no need to render LN filters for non anchor categories + if ($category && $category->getIsAnchor()) { + $result = true; + break; + } + } + } + + return $result; + } + + /** + * Get categories based on query filter data. + * + * Get categories from query will allow to check if category is anchor + * And proceed with attribute aggregation if it's not + * + * @param QueryInterface $queryExpression + * @return \Magento\Catalog\Api\Data\CategoryInterface[]|[] + */ + private function getCategoriesFromQuery(QueryInterface $queryExpression) + { + /** @var BoolExpression $queryExpression */ + $categoryIds = $this->getCategoryIdsFromQuery($queryExpression); + $categories = []; + + foreach ($categoryIds as $categoryId) { + try { + $categories[] = $this->categoryRepository + ->get($categoryId, $this->storeManager->getStore()->getId()); + } catch (NoSuchEntityException $e) { + // do nothing if category is not found by id + } + } + + return $categories; + } + + /** + * Get Category Ids from search query. + * + * Get Category Ids from Must and Should search queries. + * + * @param QueryInterface $queryExpression + * @return array + */ + private function getCategoryIdsFromQuery(QueryInterface $queryExpression) + { + $queryFilterArray = []; + /** @var BoolExpression $queryExpression */ + $queryFilterArray[] = $queryExpression->getMust(); + $queryFilterArray[] = $queryExpression->getShould(); + $categoryIds = []; + + foreach ($queryFilterArray as $item) { + if (!empty($item) && isset($item['category'])) { + $queryFilter = $item['category']; + /** @var \Magento\Framework\Search\Request\Query\Filter $queryFilter */ + $categoryIds[] = $queryFilter->getReference()->getValue(); + } + } + + return $categoryIds; + } +} diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php new file mode 100644 index 0000000000000..ce9248b6c0f10 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php @@ -0,0 +1,76 @@ +categoryRepository = $categoryRepository; + $this->storeManager = $storeManager; + $this->queryCheckers = $queryCheckers; + + foreach ($this->queryCheckers as $queryChecker) { + if (!$queryChecker instanceof RequestCheckerInterface) { + throw new \InvalidArgumentException( + get_class($queryChecker) . + ' does not implement ' . + \Magento\CatalogSearch\Model\Adapter\Aggregation\RequestCheckerInterface::class + ); + } + } + } + + /** + * {@inheritdoc} + */ + public function isApplicable(RequestInterface $request) + { + $result = true; + + foreach ($this->queryCheckers as $item) { + /** @var RequestCheckerInterface $item */ + $result = $item->isApplicable($request); + if (!$result) { + break; + } + } + + return $result; + } +} diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerInterface.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerInterface.php new file mode 100644 index 0000000000000..a4a69d55b8aba --- /dev/null +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerInterface.php @@ -0,0 +1,24 @@ +attributeSetFinder = $this->getMockBuilder(AttributeSetFinderInterface::class) @@ -68,6 +71,9 @@ protected function setUp() ) ->disableOriginalConstructor() ->getMock(); + $this->aggregationChecker = $this->getMockBuilder(RequestCheckerInterface::class) + ->disableOriginalConstructor() + ->getMock(); $this->aggregationResolver = (new ObjectManager($this))->getObject( AggregationResolver::class, @@ -76,6 +82,7 @@ protected function setUp() 'searchCriteriaBuilder' => $this->searchCriteriaBuilder, 'config' => $this->config, 'attributeCollection' => $this->attributeCollection, + 'aggregationChecker' => $this->aggregationChecker ] ); } @@ -93,6 +100,13 @@ public function testResolve() ) ->disableOriginalConstructor() ->getMockForAbstractClass(); + + $this->aggregationChecker + ->expects($this->once()) + ->method('isApplicable') + ->with($this->request) + ->willReturn(true); + $this->attributeSetFinder ->expects($this->once()) ->method('findAttributeSetIdsByProductIds') diff --git a/app/code/Magento/CatalogSearch/etc/di.xml b/app/code/Magento/CatalogSearch/etc/di.xml index 0951323d08ecc..9751a3f9cb6cc 100644 --- a/app/code/Magento/CatalogSearch/etc/di.xml +++ b/app/code/Magento/CatalogSearch/etc/di.xml @@ -1,7 +1,7 @@ @@ -13,6 +13,7 @@ + Magento\CatalogSearch\Model\ResourceModel\EngineInterface::CONFIG_ENGINE_PATH @@ -306,4 +307,22 @@ Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav\FrontendResource + + + + \Magento\CatalogSearch\Model\Adapter\Aggregation\Checker\Query\AdvancedSearch + \Magento\CatalogSearch\Model\Adapter\Aggregation\Checker\Query\CatalogView + + + + + + advanced_search_container + + + + + catalog_view_container + + From 05830238250ee7bb4b5c65747178fb1629bda712 Mon Sep 17 00:00:00 2001 From: Oleksandr Radchenko Date: Wed, 12 Apr 2017 10:47:24 +0300 Subject: [PATCH 02/11] MAGETWO-67291: [Performance] Layered Navigation built for Non Anchored categories --- .../Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php | 2 +- .../Model/Adapter/Aggregation/Checker/Query/CatalogView.php | 2 +- .../Model/Adapter/Aggregation/RequestCheckerComposite.php | 2 +- .../Model/Adapter/Aggregation/RequestCheckerInterface.php | 2 +- app/code/Magento/CatalogSearch/etc/di.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php index 79c8e4bd6c3b9..8f1f3fde14240 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php @@ -1,6 +1,6 @@ From c11d05c4c09020d31a07f73dd3b8d6159cb395cd Mon Sep 17 00:00:00 2001 From: Olga Lytvynenko Date: Fri, 14 Apr 2017 13:08:54 +0300 Subject: [PATCH 03/11] MAGETWO-64834: Spinner is Always Displayed on Shopping Cart page in Summary block for virtual quote --- .../js/model/cart/totals-processor/default.js | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js index 53fe0e4bdc2ec..280928f235656 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js @@ -45,10 +45,15 @@ define([ totals: result, address: address, cartVersion: customerData.get('cart')()['data_id'], - shippingMethodCode: quote.shippingMethod()['method_code'], - shippingCarrierCode: quote.shippingMethod()['carrier_code'] + shippingMethodCode: null, + shippingCarrierCode: null }; + if (quote.shippingMethod()) { + data.shippingMethodCode = quote.shippingMethod()['method_code']; + data.shippingCarrierCode = quote.shippingMethod()['carrier_code']; + } + quote.setTotals(result); cartCache.set('cart-data', data); }).fail(function (response) { @@ -72,9 +77,19 @@ define([ * @param {Object} address */ estimateTotals: function (address) { + var data = { + shippingMethodCode: null, + shippingCarrierCode: null + }; + + if (quote.shippingMethod()) { + data.shippingMethodCode = quote.shippingMethod()['method_code']; + data.shippingCarrierCode = quote.shippingMethod()['carrier_code']; + } + if (!cartCache.isChanged('cartVersion', customerData.get('cart')()['data_id']) && - !cartCache.isChanged('shippingMethodCode', quote.shippingMethod()['method_code']) && - !cartCache.isChanged('shippingCarrierCode', quote.shippingMethod()['carrier_code']) && + !cartCache.isChanged('shippingMethodCode', data.shippingMethodCode) && + !cartCache.isChanged('shippingCarrierCode', data.shippingCarrierCode) && !cartCache.isChanged('address', address) && cartCache.get('totals') ) { From 1ba5487b2d7ad2944791b73cac79182810322187 Mon Sep 17 00:00:00 2001 From: Olga Lytvynenko Date: Tue, 18 Apr 2017 18:07:54 +0300 Subject: [PATCH 04/11] MAGETWO-64834: Spinner is Always Displayed on Shopping Cart page in Summary block for virtual quote - Fix functional tests --- .../Test/TestCase/AddProductsToShoppingCartEntityTest.xml | 1 - .../app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml | 2 -- 2 files changed, 3 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.xml index 0dafcca251b37..e54e3081e033d 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.xml @@ -74,7 +74,6 @@ - MAGETWO-64874: Eternal loader in shipping and tax block severity:S2 downloadableProduct::with_two_separately_links 22.43 diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml index a51768947f828..e6eb81914353d 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml @@ -38,7 +38,6 @@ - MAGETWO-64874: Eternal loader in shipping and tax block severity:S0 catalogProductVirtual::default downloadableProduct::with_two_separately_links @@ -153,7 +152,6 @@ - MAGETWO-64874: Eternal loader in shipping and tax block severity:S0 catalogProductVirtual::product_50_dollar active_sales_rule_with_fixed_price_discount_coupon From fba710624f6efd80d5f158b4900bbd073e7318cc Mon Sep 17 00:00:00 2001 From: Olga Lytvynenko Date: Wed, 19 Apr 2017 16:42:17 +0300 Subject: [PATCH 05/11] MAGETWO-59826: [Github] Opengraphs og:description contains html tags #6776 --- .../frontend/templates/product/view/opengraph/general.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/opengraph/general.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/opengraph/general.phtml index b675ea01fe4b4..445950c637b7d 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/opengraph/general.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/opengraph/general.phtml @@ -10,9 +10,9 @@ ?> - + - + getProduct()->getFinalPrice()):?> From 1ffcfdeaea6a64275906153f41e4705618b54de6 Mon Sep 17 00:00:00 2001 From: Oleksandr Radchenko Date: Tue, 25 Apr 2017 13:50:07 +0300 Subject: [PATCH 06/11] MAGETWO-67291: [Performance] Layered Navigation built for Non Anchored categories --- .../Aggregation/Checker/Query/CatalogView.php | 2 +- .../Aggregation/RequestCheckerComposite.php | 4 - .../Aggregation/AggregationResolverTest.php | 11 ++ .../Checker/Query/CatalogViewTest.php | 144 ++++++++++++++++++ 4 files changed, 156 insertions(+), 5 deletions(-) create mode 100644 app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/Checker/Query/CatalogViewTest.php diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php index 01e95c4676af4..aa5bfea5e8675 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php @@ -145,4 +145,4 @@ private function getCategoryIdsFromQuery(QueryInterface $queryExpression) return $categoryIds; } -} +} \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php index 126e15b789acf..9e4f93b45985c 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php @@ -9,10 +9,6 @@ use Magento\Catalog\Api\CategoryRepositoryInterface; use Magento\Store\Model\StoreManagerInterface; -/** - * A Composite implementation for request checker. - * Checker for attribute resolver class. - */ class RequestCheckerComposite implements RequestCheckerInterface { /** diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/AggregationResolverTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/AggregationResolverTest.php index 2ca94edac1607..6dc8c87f57ba0 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/AggregationResolverTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/AggregationResolverTest.php @@ -87,6 +87,17 @@ protected function setUp() ); } + public function testIsNotAplicable() + { + $documentIds = [1]; + $this->aggregationChecker + ->expects($this->once()) + ->method('isApplicable') + ->with($this->request) + ->willReturn(false); + $this->assertEquals([], $this->aggregationResolver->resolve($this->request, $documentIds)); + } + public function testResolve() { $documentIds = [1, 2, 3]; diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/Checker/Query/CatalogViewTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/Checker/Query/CatalogViewTest.php new file mode 100644 index 0000000000000..e0d4567539d04 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/Checker/Query/CatalogViewTest.php @@ -0,0 +1,144 @@ +categoryRepositoryMock = $this->getMockBuilder(CategoryRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->requestMock = $this->getMockBuilder(RequestInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->queryFilterMock = $this->getMockBuilder(Filter::class) + ->setMethods(['getReference']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->termFilterMock = $this->getMockBuilder(Term::class) + ->setMethods(['getValue']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->storeMock = $this->getMockBuilder(StoreInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->categoryMock = $this->getMockBuilder(CategoryInterface::class) + ->setMethods(['getIsAnchor']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->queryMock = $this->getMockBuilder(QueryInterface::class) + ->setMethods(['getMust', 'getShould']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->name = 'Request'; + + $this->catalogViewMock = new CatalogView($this->categoryRepositoryMock, $this->storeManagerMock, $this->name); + } + + public function testIsApplicable() + { + $this->assertTrue($this->catalogViewMock->isApplicable($this->requestMock)); + } + + public function testIsNotApplicable() + { + $this->requestMock->expects($this->once()) + ->method('getName') + ->willReturn($this->name); + $this->requestMock->expects($this->any()) + ->method('getQuery') + ->willReturn($this->queryMock); + $this->queryMock->expects($this->once()) + ->method('getType') + ->willReturn(QueryInterface::TYPE_BOOL); + $this->queryMock->expects($this->any()) + ->method('getMust') + ->willReturn(['category' => $this->queryFilterMock]); + $this->queryFilterMock->expects($this->any()) + ->method('getReference') + ->willReturn($this->termFilterMock); + $this->termFilterMock->expects($this->any()) + ->method('getValue') + ->willReturn(1); + $this->storeManagerMock->expects($this->any()) + ->method('getStore') + ->willReturn($this->storeMock); + $this->storeMock->expects($this->any()) + ->method('getId') + ->willReturn(1); + $this->categoryRepositoryMock->expects($this->once()) + ->method('get') + ->willReturn($this->categoryMock); + $this->categoryMock->expects($this->once()) + ->method('getIsAnchor') + ->willReturn(true); + $this->assertTrue($this->catalogViewMock->isApplicable($this->requestMock)); + } +} From 6c1284a487ea861e2cef77f2b58a6671fa6aa69c Mon Sep 17 00:00:00 2001 From: Oleksandr Radchenko Date: Tue, 25 Apr 2017 15:05:46 +0300 Subject: [PATCH 07/11] MAGETWO-67291: [Performance] Layered Navigation built for Non Anchored categories --- .../Model/Adapter/Aggregation/Checker/Query/CatalogView.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php index aa5bfea5e8675..01e95c4676af4 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php @@ -145,4 +145,4 @@ private function getCategoryIdsFromQuery(QueryInterface $queryExpression) return $categoryIds; } -} \ No newline at end of file +} From c92f8a3b7308cd69ba4bd3b99c8dc4b626506368 Mon Sep 17 00:00:00 2001 From: Oleksandr Radchenko Date: Tue, 25 Apr 2017 15:52:54 +0300 Subject: [PATCH 08/11] MAGETWO-67291: [Performance] Layered Navigation built for Non Anchored categories --- .../Adapter/Aggregation/Checker/Query/CatalogViewTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/Checker/Query/CatalogViewTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/Checker/Query/CatalogViewTest.php index e0d4567539d04..a7257d6083505 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/Checker/Query/CatalogViewTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Aggregation/Checker/Query/CatalogViewTest.php @@ -138,7 +138,7 @@ public function testIsNotApplicable() ->willReturn($this->categoryMock); $this->categoryMock->expects($this->once()) ->method('getIsAnchor') - ->willReturn(true); - $this->assertTrue($this->catalogViewMock->isApplicable($this->requestMock)); + ->willReturn(false); + $this->assertFalse($this->catalogViewMock->isApplicable($this->requestMock)); } } From 56622a1e31b7863c96fe0681c68e06abcbb3e566 Mon Sep 17 00:00:00 2001 From: olysenko Date: Wed, 10 May 2017 18:31:55 +0300 Subject: [PATCH 09/11] MAGETWO-67291: [Performance] Layered Navigation built for Non Anchored categories --- .../Model/Adapter/Aggregation/AggregationResolver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php index 1feae40291f71..8ca0c0eeddf1b 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php @@ -53,16 +53,16 @@ class AggregationResolver implements AggregationResolverInterface * @param ProductAttributeRepositoryInterface $productAttributeRepository * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param Config $config - * @param RequestCheckerInterface $aggregationChecker * @param AttributeCollection $attributeCollection [optional] + * @param RequestCheckerInterface|null $aggregationChecker */ public function __construct( AttributeSetFinderInterface $attributeSetFinder, ProductAttributeRepositoryInterface $productAttributeRepository, SearchCriteriaBuilder $searchCriteriaBuilder, Config $config, - RequestCheckerInterface $aggregationChecker = null, - AttributeCollection $attributeCollection = null + AttributeCollection $attributeCollection = null, + RequestCheckerInterface $aggregationChecker = null ) { $this->attributeSetFinder = $attributeSetFinder; $this->productAttributeRepository = $productAttributeRepository; From 7103e93e8f04414ab2f2fc2b5706a60978c57be4 Mon Sep 17 00:00:00 2001 From: Olga Lytvynenko Date: Fri, 12 May 2017 16:16:54 +0300 Subject: [PATCH 10/11] MAGETWO-64834: Spinner is Always Displayed on Shopping Cart page in Summary block for virtual quote - JS unit test update --- .../js/model/cart/totals-processor/default.js | 4 ++-- .../cart/totals-processor/default.test.js | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js index 280928f235656..55be66f8b0a08 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js @@ -49,7 +49,7 @@ define([ shippingCarrierCode: null }; - if (quote.shippingMethod()) { + if (quote.shippingMethod() && quote.shippingMethod()['method_code']) { data.shippingMethodCode = quote.shippingMethod()['method_code']; data.shippingCarrierCode = quote.shippingMethod()['carrier_code']; } @@ -82,7 +82,7 @@ define([ shippingCarrierCode: null }; - if (quote.shippingMethod()) { + if (quote.shippingMethod() && quote.shippingMethod()['method_code']) { data.shippingMethodCode = quote.shippingMethod()['method_code']; data.shippingCarrierCode = quote.shippingMethod()['carrier_code']; } diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js index 2a5479dc060c1..b9d4511c56ecf 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js @@ -32,6 +32,13 @@ define([ regionId: 'California', postcode: 90210 }, + data = { + totals: result, + address: address, + cartVersion: 1, + shippingMethodCode: null, + shippingCarrierCode: null + }, mocks = { 'Magento_Checkout/js/model/resource-url-manager': { getUrlForTotalsEstimationForNewAddress: jasmine.createSpy().and.returnValue( @@ -42,8 +49,7 @@ define([ shippingMethod: ko.observable({ 'method_code': 'flatrate', 'carrier_code': 'flatrate' - } - ), + }), setTotals: jasmine.createSpy() }, 'mage/storage': { @@ -64,14 +70,8 @@ define([ get: function () { }, set: jasmine.createSpy() - } - }, - data = { - totals: result, - address: address, - cartVersion: 1, - shippingMethodCode: 'flatrate', - shippingCarrierCode: 'flatrate' + }, + data: data }, defaultProcessor; @@ -112,6 +112,9 @@ define([ ); spyOn(mocks['Magento_Checkout/js/model/cart/cache'], 'get'); spyOn(mocks['mage/storage'], 'post').and.callFake(function () { + data.shippingMethodCode = mocks['Magento_Checkout/js/model/quote'].shippingMethod()['method_code']; + data.shippingCarrierCode = mocks['Magento_Checkout/js/model/quote'].shippingMethod()['carrier_code']; + return new $.Deferred().resolve(result); }); expect(defaultProcessor.estimateTotals(address)).toBeUndefined(); From 9ce1d5c7aac5c0efa3f066931b8e6cbeda0f0c48 Mon Sep 17 00:00:00 2001 From: Olga Lytvynenko Date: Fri, 12 May 2017 17:33:13 +0300 Subject: [PATCH 11/11] MAGETWO-64834: Spinner is Always Displayed on Shopping Cart page in Summary block for virtual quote - JS unit test update --- .../frontend/js/model/cart/totals-processor/default.test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js index b9d4511c56ecf..6476432c027a2 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js @@ -70,8 +70,7 @@ define([ get: function () { }, set: jasmine.createSpy() - }, - data: data + } }, defaultProcessor;