From 02b9213e4468bfa765ecc38ee55657662554fd72 Mon Sep 17 00:00:00 2001 From: Oleksandr Karpenko Date: Wed, 2 Mar 2016 14:58:23 +0200 Subject: [PATCH 01/18] MAGETWO-49965: Remove abstract controllers (save, delete) from staging --- lib/internal/Magento/Framework/Model/AbstractModel.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/internal/Magento/Framework/Model/AbstractModel.php b/lib/internal/Magento/Framework/Model/AbstractModel.php index f72c455daf860..602f85d54c568 100644 --- a/lib/internal/Magento/Framework/Model/AbstractModel.php +++ b/lib/internal/Magento/Framework/Model/AbstractModel.php @@ -506,6 +506,7 @@ public function getCollection() /** * Load object data * + * @deprecated * @param integer $modelId * @param null|string $field * @return $this @@ -607,6 +608,7 @@ public function setHasDataChanges($flag) /** * Save object data * + * @deprecated * @return $this * @throws \Exception */ @@ -791,6 +793,7 @@ public function afterSave() /** * Delete object from database * + * @deprecated * @return $this * @throws \Exception */ From c128538f75f682adaf5c3fc1e22a3c0b1b5df856 Mon Sep 17 00:00:00 2001 From: Sviatoslav Mankivskyi Date: Thu, 3 Mar 2016 15:18:37 +0200 Subject: [PATCH 02/18] MAGETWO-49900: Product Repository Cache fix --- app/code/Magento/Catalog/Model/ProductRepository.php | 4 ++++ .../Catalog/Test/Unit/Model/ProductRepositoryTest.php | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index 9f1087544ae23..48dcbdf4439ec 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -508,6 +508,8 @@ public function save(\Magento\Catalog\Api\Data\ProductInterface $product, $saveO if ($tierPrices !== null) { $product->setData('tier_price', $tierPrices); } + unset($this->instances[$product->getSku()]); + unset($this->instancesById[$product->getId()]); $this->resourceModel->save($product); } catch (\Magento\Eav\Model\Entity\Attribute\Exception $exception) { throw \Magento\Framework\Exception\InputException::invalidFieldValue( @@ -531,6 +533,8 @@ public function delete(\Magento\Catalog\Api\Data\ProductInterface $product) $sku = $product->getSku(); $productId = $product->getId(); try { + unset($this->instances[$product->getSku()]); + unset($this->instancesById[$product->getId()]); $this->resourceModel->delete($product); } catch (\Exception $e) { throw new \Magento\Framework\Exception\StateException( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index 43aa01721c584..da7032649f473 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -539,7 +539,7 @@ public function testSaveException() ->willReturn(true); $this->resourceModelMock->expects($this->once())->method('save')->with($this->productMock) ->willThrowException(new \Magento\Eav\Model\Entity\Attribute\Exception(__('123'))); - $this->productMock->expects($this->never())->method('getId'); + $this->productMock->expects($this->once())->method('getId')->willReturn(null); $this->extensibleDataObjectConverterMock ->expects($this->once()) ->method('toNestedArray') @@ -574,7 +574,8 @@ public function testSaveInvalidProductException() public function testDelete() { - $this->productMock->expects($this->once())->method('getSku')->willReturn('product-42'); + $this->productMock->expects($this->exactly(2))->method('getSku')->willReturn('product-42'); + $this->productMock->expects($this->exactly(2))->method('getId')->willReturn(42); $this->resourceModelMock->expects($this->once())->method('delete')->with($this->productMock) ->willReturn(true); $this->assertTrue($this->model->delete($this->productMock)); @@ -586,7 +587,8 @@ public function testDelete() */ public function testDeleteException() { - $this->productMock->expects($this->once())->method('getSku')->willReturn('product-42'); + $this->productMock->expects($this->exactly(2))->method('getSku')->willReturn('product-42'); + $this->productMock->expects($this->exactly(2))->method('getId')->willReturn(42); $this->resourceModelMock->expects($this->once())->method('delete')->with($this->productMock) ->willThrowException(new \Exception()); $this->model->delete($this->productMock); From 394e20a3ba91402b4b49cf7505d4377352efa5d5 Mon Sep 17 00:00:00 2001 From: Sviatoslav Mankivskyi Date: Fri, 4 Mar 2016 14:16:03 +0200 Subject: [PATCH 03/18] MAGETWO-49900: Product Repository Cache fix --- .../testsuite/Magento/Bundle/_files/product_rollback.php | 2 +- .../testsuite/Magento/Catalog/_files/categories_rollback.php | 2 +- .../Catalog/_files/indexer_catalog_category_rollback.php | 2 +- .../Magento/Catalog/_files/multiple_products_rollback.php | 2 +- .../Magento/Catalog/_files/price_row_fixture_rollback.php | 2 +- .../Magento/Catalog/_files/product_associated_rollback.php | 2 +- .../Magento/Catalog/_files/product_group_prices_rollback.php | 2 +- .../Catalog/_files/product_simple_duplicated_rollback.php | 2 +- .../Catalog/_files/product_simple_multistore_rollback.php | 2 +- .../Magento/Catalog/_files/product_simple_rollback.php | 2 +- .../Magento/Catalog/_files/product_virtual_rollback.php | 2 +- .../Catalog/_files/product_with_dropdown_option_rollback.php | 2 +- .../Magento/Catalog/_files/product_with_options_rollback.php | 2 +- .../Catalog/_files/product_without_options_rollback.php | 2 +- .../Magento/Catalog/_files/products_crosssell_rollback.php | 4 ++-- .../Magento/Catalog/_files/products_new_rollback.php | 2 +- .../Magento/Catalog/_files/products_related_rollback.php | 4 ++-- .../testsuite/Magento/Catalog/_files/products_rollback.php | 4 ++-- .../Magento/Catalog/_files/url_rewrites_rollback.php | 2 +- .../_files/product_configurable_rollback.php | 2 +- .../Downloadable/_files/product_downloadable_rollback.php | 2 +- .../GroupedProduct/_files/product_grouped_rollback.php | 4 ++-- .../testsuite/Magento/Sales/_files/quote_rollback.php | 2 +- 23 files changed, 27 insertions(+), 27 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Bundle/_files/product_rollback.php b/dev/tests/integration/testsuite/Magento/Bundle/_files/product_rollback.php index d0c016d63ca1b..100c5e78f5aa3 100644 --- a/dev/tests/integration/testsuite/Magento/Bundle/_files/product_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Bundle/_files/product_rollback.php @@ -19,7 +19,7 @@ $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $product = $productRepository->get('bundle-product'); + $product = $productRepository->get('bundle-product', false, null, true); $productRepository->delete($product); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { //Product already removed diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_rollback.php index e114f71d09d0c..b3b16b0788274 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_rollback.php @@ -18,7 +18,7 @@ foreach ($productsToDelete as $sku) { try { - $product = $productRepository->get($sku); + $product = $productRepository->get($sku, false, null, true); $productRepository->delete($product); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { //Product already removed diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/indexer_catalog_category_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/indexer_catalog_category_rollback.php index c9209b78f61ae..ddd77a554fc57 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/indexer_catalog_category_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/indexer_catalog_category_rollback.php @@ -18,7 +18,7 @@ foreach (['simple 01', 'simple 02', 'simple 03'] as $sku) { try { - $product = $productRepository->get($sku); + $product = $productRepository->get($sku, false, null, true); $productRepository->delete($product); } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { //Product already removed diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/multiple_products_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/multiple_products_rollback.php index e02133229b434..212c8e53200a3 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/multiple_products_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/multiple_products_rollback.php @@ -17,7 +17,7 @@ foreach (['simple1', 'simple2', 'simple3'] as $sku) { try { - $product = $productRepository->get($sku); + $product = $productRepository->get($sku, false, null, true); $productRepository->delete($product); } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { //Product already removed diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/price_row_fixture_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/price_row_fixture_rollback.php index 6e025caeeb270..befd8ca541756 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/price_row_fixture_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/price_row_fixture_rollback.php @@ -17,7 +17,7 @@ 'Magento\Catalog\Model\ProductRepository' ); try { - $product = $repository->get('simple'); + $product = $repository->get('simple', false, null, true); $product->delete(); } catch (NoSuchEntityException $e) { //Entity already deleted diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_associated_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_associated_rollback.php index 613c72fb5fc89..0a80717c990e3 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_associated_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_associated_rollback.php @@ -15,7 +15,7 @@ 'Magento\Catalog\Model\ProductRepository' ); try { - $product = $repository->get('simple'); + $product = $repository->get('simple', false, null, true); $product->delete(); } catch (NoSuchEntityException $e) { //Entity already deleted diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_group_prices_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_group_prices_rollback.php index 387509efd7d63..0621f94fe9adc 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_group_prices_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_group_prices_rollback.php @@ -14,7 +14,7 @@ 'Magento\Catalog\Model\ProductRepository' ); try { - $product = $repository->get('simple'); + $product = $repository->get('simple', false, null, true); $product->delete(); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { //Entity already deleted diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_duplicated_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_duplicated_rollback.php index 50f977ff615b1..0763e4d406b53 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_duplicated_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_duplicated_rollback.php @@ -16,7 +16,7 @@ $productRepository = $objectManager->create('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $product = $productRepository->get('simple-1'); + $product = $productRepository->get('simple-1', false, null, true); $productRepository->delete($product); } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { //Product already removed diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_rollback.php index addd42ebfc706..0b4c6a015fe36 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_rollback.php @@ -14,7 +14,7 @@ 'Magento\Catalog\Model\ProductRepository' ); try { - $product = $repository->get('simple'); + $product = $repository->get('simple', false, null, true); $product->delete(); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { //Entity already deleted diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_rollback.php index 493334cc6fce6..f733075176b17 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_rollback.php @@ -17,7 +17,7 @@ $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $product = $productRepository->get('simple'); + $product = $productRepository->get('simple', false, null, true); $productRepository->delete($product); } catch (NoSuchEntityException $e) { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_virtual_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_virtual_rollback.php index 98732a95a1307..04037eaaae785 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_virtual_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_virtual_rollback.php @@ -15,7 +15,7 @@ ->create('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $product = $productRepository->get('virtual-product'); + $product = $productRepository->get('virtual-product', false, null, true); $productRepository->delete($product); } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { //Product already removed diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_dropdown_option_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_dropdown_option_rollback.php index db482d165660b..6ecaeab5f89f3 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_dropdown_option_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_dropdown_option_rollback.php @@ -15,7 +15,7 @@ $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $product = $productRepository->get('simple_dropdown_option'); + $product = $productRepository->get('simple_dropdown_option', false, null, true); $product->delete(); } catch (NoSuchEntityException $e) { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_options_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_options_rollback.php index eddc5632f7c3b..15f422899a3fd 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_options_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_options_rollback.php @@ -14,7 +14,7 @@ 'Magento\Catalog\Model\ProductRepository' ); try { - $product = $repository->get('simple'); + $product = $repository->get('simple', false, null, true); $product->delete(); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { //Entity already deleted diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_without_options_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_without_options_rollback.php index eddc5632f7c3b..15f422899a3fd 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_without_options_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_without_options_rollback.php @@ -14,7 +14,7 @@ 'Magento\Catalog\Model\ProductRepository' ); try { - $product = $repository->get('simple'); + $product = $repository->get('simple', false, null, true); $product->delete(); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { //Entity already deleted diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_crosssell_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_crosssell_rollback.php index 37705cf6d7569..8a4e66cdb2136 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_crosssell_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_crosssell_rollback.php @@ -16,14 +16,14 @@ $productRepository = $objectManager->create('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $firstProduct = $productRepository->get('simple'); + $firstProduct = $productRepository->get('simple', false, null, true); $firstProduct->delete(); } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { //Product already removed } try { - $secondProduct = $productRepository->get('simple_with_cross'); + $secondProduct = $productRepository->get('simple_with_cross', false, null, true); $secondProduct->delete(); } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { //Product already removed diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_new_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_new_rollback.php index cce6ceee9bbeb..a368c71984e1f 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_new_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_new_rollback.php @@ -16,7 +16,7 @@ $productRepository = $objectManager->create('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $firstProduct = $productRepository->get('simple'); + $firstProduct = $productRepository->get('simple', false, null, true); $productRepository->delete($firstProduct); } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { //Product already removed diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_related_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_related_rollback.php index a58176f847579..cc3b5ba4b627e 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_related_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_related_rollback.php @@ -16,14 +16,14 @@ $productRepository = $objectManager->create('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $firstProduct = $productRepository->get('simple'); + $firstProduct = $productRepository->get('simple', false, null, true); $productRepository->delete($firstProduct); } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { //Product already removed } try { - $secondProduct = $productRepository->get('simple_with_cross'); + $secondProduct = $productRepository->get('simple_with_cross', false, null, true); $productRepository->delete($secondProduct); } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { //Product already removed diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_rollback.php index fe0a3b7dcee7b..937acbc353cbe 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_rollback.php @@ -16,14 +16,14 @@ $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $product = $productRepository->get('simple'); + $product = $productRepository->get('simple', false, null, true); $productRepository->delete($product); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { //Product already removed } try { - $customDesignProduct = $productRepository->get('custom-design-simple-product'); + $customDesignProduct = $productRepository->get('custom-design-simple-product', false, null, true); $productRepository->delete($customDesignProduct); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { //Product already removed diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/url_rewrites_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/url_rewrites_rollback.php index 5df750399d340..6f7a39fd4acd1 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/url_rewrites_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/url_rewrites_rollback.php @@ -15,7 +15,7 @@ ->create('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $product = $productRepository->get('simple'); + $product = $productRepository->get('simple', false, null, true); $productRepository->delete($product); } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { //Product already removed diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_rollback.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_rollback.php index 5c55c5854ec06..50c740c3ad06e 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_rollback.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_rollback.php @@ -18,7 +18,7 @@ foreach (['simple_10', 'simple_20', 'configurable'] as $sku) { try { - $product = $productRepository->get($sku); + $product = $productRepository->get($sku, false, null, true); $stockStatus = $objectManager->create('Magento\CatalogInventory\Model\Stock\Status'); $stockStatus->load($product->getEntityId(), 'product_id'); diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_rollback.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_rollback.php index 08b9da6388c29..c7496dbce8f24 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_rollback.php @@ -17,7 +17,7 @@ $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $product = $productRepository->get('downloadable-product'); + $product = $productRepository->get('downloadable-product', false, null, true); $productRepository->delete($product); } catch (NoSuchEntityException $e) { diff --git a/dev/tests/integration/testsuite/Magento/GroupedProduct/_files/product_grouped_rollback.php b/dev/tests/integration/testsuite/Magento/GroupedProduct/_files/product_grouped_rollback.php index b885ddcb1fe3a..dd6e898cc0302 100644 --- a/dev/tests/integration/testsuite/Magento/GroupedProduct/_files/product_grouped_rollback.php +++ b/dev/tests/integration/testsuite/Magento/GroupedProduct/_files/product_grouped_rollback.php @@ -18,7 +18,7 @@ $registry->register('isSecureArea', true); try { /** @var $simpleProduct \Magento\Catalog\Model\Product */ - $simpleProduct = $productRepository->get('simple-1'); + $simpleProduct = $productRepository->get('simple-1', false, null, true); $simpleProduct->delete(); } catch (NoSuchEntityException $e) { //already deleted @@ -35,7 +35,7 @@ try { /** @var $groupedProduct \Magento\Catalog\Model\Product */ - $groupedProduct = $productRepository->get('grouped-product'); + $groupedProduct = $productRepository->get('grouped-product', false, null, true); $groupedProduct->delete(); } catch (NoSuchEntityException $e) { //already deleted diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quote_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_rollback.php index 142e320b40e7a..09909174ee3ff 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/quote_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_rollback.php @@ -21,7 +21,7 @@ ->create('Magento\Catalog\Api\ProductRepositoryInterface'); try { - $product = $productRepository->get('simple'); + $product = $productRepository->get('simple', false, null, true); $productRepository->delete($product); } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { //Product already removed From bad187cb21eb04220df77aa9da5e5da1b93da4de Mon Sep 17 00:00:00 2001 From: Volodymyr Sevostianov Date: Fri, 4 Mar 2016 15:30:47 +0200 Subject: [PATCH 04/18] MAGETWO-50148: Fix CreateCustomerGroupEntityTest --- .../Adminhtml/Product/Edit/Section/AdvancedPricing.php | 2 +- .../Promo/Catalog/Edit/Section/RuleInformation.php | 2 +- .../Constraint/AssertCustomerGroupOnCartPriceRuleForm.php | 6 +++--- .../AssertCustomerGroupOnCatalogPriceRuleForm.php | 2 +- .../Adminhtml/Promo/Quote/Edit/Section/RuleInformation.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php index a2ae2c7ba9ced..e9b2568d13ab4 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/AdvancedPricing.php @@ -98,7 +98,7 @@ public function getFieldsData($fields = null, SimpleElement $element = null) */ public function getTierPriceForm(SimpleElement $element = null) { - $element = $element ?: $this->_rootElement->find($this->tierPrice); + $element = $element ?: $this->browser->find($this->advancedPricingRootElement); return $this->blockFactory->create( 'Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\AdvancedPricing\OptionTier', ['element' => $element] diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/Section/RuleInformation.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/Section/RuleInformation.php index d56cbf0b0b7bd..93faa37225865 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/Section/RuleInformation.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/Section/RuleInformation.php @@ -18,7 +18,7 @@ class RuleInformation extends Section * * @var string */ - protected $customerGroup = '#rule_customer_group_ids'; + protected $customerGroup = '[name=customer_group_ids]'; /** * Check whether Customer Group is visible. diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCartPriceRuleForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCartPriceRuleForm.php index 5f49cbee1e5a4..30fff8c5bdb15 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCartPriceRuleForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCartPriceRuleForm.php @@ -8,7 +8,7 @@ use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Mtf\Constraint\AbstractConstraint; -use Magento\SalesRule\Test\Block\Adminhtml\Promo\Quote\Edit\Tab\RuleInformation; +use Magento\SalesRule\Test\Block\Adminhtml\Promo\Quote\Edit\Section\RuleInformation; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteNew; @@ -32,10 +32,10 @@ public function processAssert( ) { $promoQuoteIndex->open(); $promoQuoteIndex->getGridPageActions()->addNew(); - $promoQuoteNew->getSalesRuleForm()->openTab('rule_information'); + $promoQuoteNew->getSalesRuleForm()->openSection('rule_information'); /** @var RuleInformation $ruleInformationTab */ - $ruleInformationTab = $promoQuoteNew->getSalesRuleForm()->getTab('rule_information'); + $ruleInformationTab = $promoQuoteNew->getSalesRuleForm()->getSection('rule_information'); \PHPUnit_Framework_Assert::assertTrue( $ruleInformationTab->isVisibleCustomerGroup($customerGroup), "Customer group {$customerGroup->getCustomerGroupCode()} not in cart price rule page." diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCatalogPriceRuleForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCatalogPriceRuleForm.php index 74a176c341203..236c118811e4c 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCatalogPriceRuleForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCatalogPriceRuleForm.php @@ -32,7 +32,7 @@ public function processAssert( ) { $catalogRuleIndex->open(); $catalogRuleIndex->getGridPageActions()->addNew(); - $catalogRuleNew->getEditForm()->openTab('rule_information'); + $catalogRuleNew->getEditForm()->openSection('rule_information'); /** @var RuleInformation $ruleInformationSection */ $ruleInformationSection = $catalogRuleNew->getEditForm()->getSection('rule_information'); diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Section/RuleInformation.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Section/RuleInformation.php index 911c33f10dc4b..71fee22605bdc 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Section/RuleInformation.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Section/RuleInformation.php @@ -20,7 +20,7 @@ class RuleInformation extends Section * * @var string */ - protected $customerGroup = '#rule_customer_group_ids'; + protected $customerGroup = '[name=customer_group_ids]'; /** * Get data of section. From 35f20e00fe6cf1bc60832c509384c52edd248689 Mon Sep 17 00:00:00 2001 From: Maxim Medinskiy Date: Fri, 4 Mar 2016 17:09:48 +0200 Subject: [PATCH 05/18] MAGETWO-49449: Redundant get request if customer has items in shopping cart --- .../Customer/view/frontend/web/js/customer-data.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js index 70db1def12ac9..8f2137b232566 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js +++ b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js @@ -93,10 +93,19 @@ define([ * @return {*} */ ko.extenders.disposableCustomerData = function (target, sectionName) { - storage.remove(sectionName); + var sectionDataIds, newSectionDataIds = []; target.subscribe(function () { setTimeout(function () { + var sectionId; storage.remove(sectionName); + sectionDataIds = $.cookieStorage.get('section_data_ids') || {}; + _.each(sectionDataIds, function (data, name) { + if (name == sectionName) { + sectionId = data['data_id']; + newSectionDataIds[name] = sectionId; + } + }); + $.cookieStorage.set('section_data_ids', newSectionDataIds); }, 3000); }); From 21d65041624c717334dbe3f67e1856d033854480 Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Mon, 7 Mar 2016 14:28:19 +0200 Subject: [PATCH 06/18] MAGETWO-47543: Fix prepare data method --- .../Framework/Model/ResourceModel/Db/UpdateEntityRow.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/UpdateEntityRow.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/UpdateEntityRow.php index 26e52091d63c9..fc4d58e95f6ea 100755 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/UpdateEntityRow.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/UpdateEntityRow.php @@ -41,7 +41,7 @@ protected function prepareData(EntityMetadata $metadata, $data) if ($column['DEFAULT'] == 'CURRENT_TIMESTAMP' || $column['IDENTITY']) { continue; } - if (isset($data[strtolower($column['COLUMN_NAME'])])) { + if (array_key_exists(strtolower($column['COLUMN_NAME']), $data)) { $output[strtolower($column['COLUMN_NAME'])] = $data[strtolower($column['COLUMN_NAME'])]; } } From f6af49acf98080cc67f529a5f19cb5e09be25363 Mon Sep 17 00:00:00 2001 From: Sviatoslav Mankivskyi Date: Mon, 7 Mar 2016 14:39:12 +0200 Subject: [PATCH 07/18] MAGETWO-49900: Product Repository Cache fix --- .../Model/Product/Type/Configurable/PriceTest.php | 6 ------ .../ConfigurableProduct/_files/product_configurable.php | 2 ++ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/Configurable/PriceTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/Configurable/PriceTest.php index 24c80a4a6111b..23918aeecd364 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/Configurable/PriceTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/Configurable/PriceTest.php @@ -28,7 +28,6 @@ protected function setUp() } /** - * @magentoDbIsolation enabled * @magentoDataFixture Magento/ConfigurableProduct/_files/tax_rule.php * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php */ @@ -39,7 +38,6 @@ public function testGetFinalPrice() /** * @magentoConfigFixture current_store tax/display/type 1 - * @magentoDbIsolation enabled * @magentoDataFixture Magento/ConfigurableProduct/_files/tax_rule.php * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php */ @@ -50,7 +48,6 @@ public function testGetFinalPriceExcludingTax() /** * @magentoConfigFixture current_store tax/display/type 2 - * @magentoDbIsolation enabled * @magentoDataFixture Magento/ConfigurableProduct/_files/tax_rule.php * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php */ @@ -62,7 +59,6 @@ public function testGetFinalPriceIncludingTax() /** * @magentoConfigFixture current_store tax/display/type 3 - * @magentoDbIsolation enabled * @magentoDataFixture Magento/ConfigurableProduct/_files/tax_rule.php * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php */ @@ -73,7 +69,6 @@ public function testGetFinalPriceIncludingExcludingTax() } /** - * @magentoDbIsolation enabled * @magentoDataFixture Magento/ConfigurableProduct/_files/tax_rule.php * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php */ @@ -85,7 +80,6 @@ public function testGetFinalPriceWithSelectedSimpleProduct() } /** - * @magentoDbIsolation enabled * @magentoDataFixture Magento/ConfigurableProduct/_files/tax_rule.php * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php */ diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable.php index 7f7b89f4146e1..45a41ed120265 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable.php @@ -15,6 +15,8 @@ use Magento\Eav\Api\Data\AttributeOptionInterface; use Magento\TestFramework\Helper\Bootstrap; +\Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(); + require __DIR__ . '/configurable_attribute.php'; /** @var ProductRepositoryInterface $productRepository */ From 53ccc7f47882d0fdf1c9c0c0c6a6ac1df110567b Mon Sep 17 00:00:00 2001 From: Maxim Medinskiy Date: Mon, 7 Mar 2016 18:30:21 +0200 Subject: [PATCH 08/18] MAGETWO-49449: Redundant get request if customer has items in shopping cart --- app/code/Magento/Customer/view/frontend/web/js/customer-data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js index 8f2137b232566..2ef374cba1000 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js +++ b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js @@ -100,7 +100,7 @@ define([ storage.remove(sectionName); sectionDataIds = $.cookieStorage.get('section_data_ids') || {}; _.each(sectionDataIds, function (data, name) { - if (name == sectionName) { + if (name != sectionName) { sectionId = data['data_id']; newSectionDataIds[name] = sectionId; } From 0c3015147deea30c27a0268c5e7e0bfbd4c63d8d Mon Sep 17 00:00:00 2001 From: Volodymyr Sevostianov Date: Wed, 9 Mar 2016 11:22:19 +0200 Subject: [PATCH 09/18] MAGETWO-50148: Fix CreateCustomerGroupEntityTest --- .../Test/TestCase/MassDeleteCustomerBackendEntityTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest.php index b68c1850d0c5f..697829712742e 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/MassDeleteCustomerBackendEntityTest.php @@ -74,6 +74,8 @@ public function __inject( $this->fixtureFactory = $fixtureFactory; $this->customerIndexPage = $customerIndexPage; $this->customerIndexEditPage = $customerIndexEditPage; + $customerIndexPage->open(); + $customerIndexPage->getCustomerGridBlock()->massaction([], 'Delete', true, 'Select All'); } /** From 3187be2b10b06071d11a77550ff5b9baa6ff85a8 Mon Sep 17 00:00:00 2001 From: Oleksandr Karpenko Date: Wed, 9 Mar 2016 18:07:34 +0200 Subject: [PATCH 10/18] MAGETWO-49965: Remove abstract controllers (save, delete) from staging --- lib/internal/Magento/Framework/Model/AbstractModel.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Model/AbstractModel.php b/lib/internal/Magento/Framework/Model/AbstractModel.php index 602f85d54c568..0fc169569ac30 100644 --- a/lib/internal/Magento/Framework/Model/AbstractModel.php +++ b/lib/internal/Magento/Framework/Model/AbstractModel.php @@ -263,7 +263,6 @@ public function getIdFieldName() return $this->_idFieldName; } - /** * Identifier getter * From 016d9fd95e59c70a35db7cbbc6c166a43b82a1ed Mon Sep 17 00:00:00 2001 From: Oleksandr Karpenko Date: Wed, 9 Mar 2016 19:02:57 +0200 Subject: [PATCH 11/18] MAGETWO-49965: Remove abstract controllers (save, delete) from staging --- app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php | 8 -------- app/code/Magento/Cms/Model/ResourceModel/Block.php | 8 -------- app/code/Magento/Cms/Model/ResourceModel/Page.php | 8 -------- app/code/Magento/SalesRule/Model/ResourceModel/Rule.php | 8 -------- 4 files changed, 32 deletions(-) diff --git a/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php b/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php index d07b3defedeb5..bc1742a622b3d 100644 --- a/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php +++ b/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php @@ -250,16 +250,8 @@ public function save(\Magento\Framework\Model\AbstractModel $object) if ($object->isDeleted()) { return $this->delete($object); } - $this->beginTransaction(); - try { - if (!$this->isModified($object)) { - $this->processNotModifiedSave($object); - $this->commit(); - $object->setHasDataChanges(false); - return $this; - } $object->validateBeforeSave(); $object->beforeSave(); if ($object->isSaveAllowed()) { diff --git a/app/code/Magento/Cms/Model/ResourceModel/Block.php b/app/code/Magento/Cms/Model/ResourceModel/Block.php index c0a2ec71cba82..c4c8886c2c8d3 100644 --- a/app/code/Magento/Cms/Model/ResourceModel/Block.php +++ b/app/code/Magento/Cms/Model/ResourceModel/Block.php @@ -236,16 +236,8 @@ public function save(AbstractModel $object) if ($object->isDeleted()) { return $this->delete($object); } - $this->beginTransaction(); - try { - if (!$this->isModified($object)) { - $this->processNotModifiedSave($object); - $this->commit(); - $object->setHasDataChanges(false); - return $this; - } $object->validateBeforeSave(); $object->beforeSave(); if ($object->isSaveAllowed()) { diff --git a/app/code/Magento/Cms/Model/ResourceModel/Page.php b/app/code/Magento/Cms/Model/ResourceModel/Page.php index f18f2f6f32070..f6beb3edc8b4e 100644 --- a/app/code/Magento/Cms/Model/ResourceModel/Page.php +++ b/app/code/Magento/Cms/Model/ResourceModel/Page.php @@ -386,16 +386,8 @@ public function save(AbstractModel $object) if ($object->isDeleted()) { return $this->delete($object); } - $this->beginTransaction(); - try { - if (!$this->isModified($object)) { - $this->processNotModifiedSave($object); - $this->commit(); - $object->setHasDataChanges(false); - return $this; - } $object->validateBeforeSave(); $object->beforeSave(); if ($object->isSaveAllowed()) { diff --git a/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php b/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php index 122bee0b2c38a..0581cdba57d21 100644 --- a/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php +++ b/app/code/Magento/SalesRule/Model/ResourceModel/Rule.php @@ -373,16 +373,8 @@ public function save(\Magento\Framework\Model\AbstractModel $object) if ($object->isDeleted()) { return $this->delete($object); } - $this->beginTransaction(); - try { - if (!$this->isModified($object)) { - $this->processNotModifiedSave($object); - $this->commit(); - $object->setHasDataChanges(false); - return $this; - } $object->validateBeforeSave(); $object->beforeSave(); if ($object->isSaveAllowed()) { From 5f4a5d614a0c449c930b0c5412fc194e9050211b Mon Sep 17 00:00:00 2001 From: Maxim Medinskiy Date: Wed, 9 Mar 2016 21:01:32 +0200 Subject: [PATCH 12/18] MAGETWO-49449: Redundant get request if customer has items in shopping cart --- .../Customer/view/frontend/web/js/customer-data.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js index 2ef374cba1000..c3748640ae067 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js +++ b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js @@ -93,16 +93,14 @@ define([ * @return {*} */ ko.extenders.disposableCustomerData = function (target, sectionName) { - var sectionDataIds, newSectionDataIds = []; + var sectionDataIds, newSectionDataIds = {}; target.subscribe(function () { setTimeout(function () { - var sectionId; storage.remove(sectionName); sectionDataIds = $.cookieStorage.get('section_data_ids') || {}; _.each(sectionDataIds, function (data, name) { if (name != sectionName) { - sectionId = data['data_id']; - newSectionDataIds[name] = sectionId; + newSectionDataIds[name] = data; } }); $.cookieStorage.set('section_data_ids', newSectionDataIds); @@ -211,7 +209,7 @@ define([ if (!_.isEmpty(privateContent)) { countryData = this.get('directory-data'); if (_.isEmpty(countryData())) { - countryData(customerData.reload(['directory-data'], false)); + customerData.reload(['directory-data'], false); } } }, @@ -308,6 +306,7 @@ define([ sectionsNamesForInvalidation; sectionsNamesForInvalidation = _.contains(sectionNames, '*') ? buffer.keys() : sectionNames; + sectionsNamesForInvalidation = sectionConfig.filterClientSideSections(sectionsNamesForInvalidation); buffer.remove(sectionsNamesForInvalidation); sectionDataIds = $.cookieStorage.get('section_data_ids') || {}; From 7711756addef211e35017b6b9b1bb2805e58e691 Mon Sep 17 00:00:00 2001 From: Maxim Medinskiy Date: Tue, 15 Mar 2016 19:32:06 +0200 Subject: [PATCH 13/18] MAGETWO-49449: Redundant get request if customer has items in shopping cart --- app/code/Magento/Customer/view/frontend/web/js/customer-data.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js index c3748640ae067..eb12d1d09014e 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js +++ b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js @@ -306,7 +306,6 @@ define([ sectionsNamesForInvalidation; sectionsNamesForInvalidation = _.contains(sectionNames, '*') ? buffer.keys() : sectionNames; - sectionsNamesForInvalidation = sectionConfig.filterClientSideSections(sectionsNamesForInvalidation); buffer.remove(sectionsNamesForInvalidation); sectionDataIds = $.cookieStorage.get('section_data_ids') || {}; From 276656db433e164432f8b5cdebdf417984e16e41 Mon Sep 17 00:00:00 2001 From: Maxim Medinskiy Date: Wed, 16 Mar 2016 17:42:48 +0200 Subject: [PATCH 14/18] MAGETWO-49449: Redundant get request if customer has items in shopping cart --- .../Customer/view/frontend/web/js/customer-data.js | 8 ++++++-- .../Customer/view/frontend/web/js/section-config.js | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js index eb12d1d09014e..d0178d96210d7 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js +++ b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js @@ -173,7 +173,9 @@ define([ remove: function (sections) { _.each(sections, function (sectionName) { storage.remove(sectionName); - storageInvalidation.set(sectionName, true); + if (!sectionConfig.isClientSideSection(sectionName)) { + storageInvalidation.set(sectionName, true); + } }); } }; @@ -311,7 +313,9 @@ define([ // Invalidate section in cookie (increase version of section with 1000) _.each(sectionsNamesForInvalidation, function (sectionName) { - sectionDataIds[sectionName] += 1000; + if (!sectionConfig.isClientSideSection(sectionName)) { + sectionDataIds[sectionName] += 1000; + } }); $.cookieStorage.set('section_data_ids', sectionDataIds); }, diff --git a/app/code/Magento/Customer/view/frontend/web/js/section-config.js b/app/code/Magento/Customer/view/frontend/web/js/section-config.js index 35b05604821fa..f04b6e2597324 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/section-config.js +++ b/app/code/Magento/Customer/view/frontend/web/js/section-config.js @@ -34,12 +34,16 @@ define(['underscore'], function (_) { }, filterClientSideSections: function (sections) { - if (_.isArray(sections)) { + if (Array.isArray(sections)) { return _.difference(sections, clientSideSections); } return sections; }, + isClientSideSection: function (sectionName) { + return _.contains(clientSideSections, sectionName); + }, + 'Magento_Customer/js/section-config': function(options) { baseUrls = options.baseUrls; sections = options.sections; From b217a89498a83e3e23468b909882d64de275b699 Mon Sep 17 00:00:00 2001 From: okarpenko Date: Thu, 17 Mar 2016 13:13:51 +0200 Subject: [PATCH 15/18] MAGETWO-49697: Add user friendly error message to DiConfigFilesTest --- .../Test/Integrity/Modular/DiConfigFilesTest.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/DiConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/DiConfigFilesTest.php index b9c4c7cbb9471..770cd155169eb 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/DiConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/DiConfigFilesTest.php @@ -55,11 +55,12 @@ protected function _prepareFiles() } /** + * @param string $filePath * @param string $xml - * @return void + * @throws \Exception * @dataProvider linearFilesProvider */ - public function testDiConfigFileWithoutMerging($xml) + public function testDiConfigFileWithoutMerging($filePath, $xml) { /** @var \Magento\Framework\ObjectManager\Config\SchemaLocator $schemaLocator */ $schemaLocator = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( @@ -74,7 +75,10 @@ public function testDiConfigFileWithoutMerging($xml) libxml_use_internal_errors(false); if (!empty($result)) { - $this->fail('File ' . $xml . ' has invalid xml structure.'); + $this->fail( + 'File ' . $filePath . ' has invalid xml structure. ' + . implode("\n", $result) + ); } } @@ -91,8 +95,8 @@ public function linearFilesProvider() } $output = []; - foreach ($common as $path => $file) { - $output[substr($path, strlen(BP))] = [$file]; + foreach ($common as $path => $content) { + $output[] = [substr($path, strlen(BP)), $content]; } return $output; From 25b05ecadbd6462ee19f7c544e361f910570d4e2 Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Thu, 17 Mar 2016 13:49:55 +0200 Subject: [PATCH 16/18] MAGETWO-50248: Customer grid indexer is too slow --- app/code/Magento/Customer/etc/di.xml | 20 ------------------- app/code/Magento/Customer/etc/indexer.xml | 1 - .../ui_component/customer_listing.xml | 12 ----------- 3 files changed, 33 deletions(-) diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index 03747e91db659..22afeb098ea44 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -205,26 +205,6 @@ BillingAddressExpression - - - LastVisitAtSubSelect - - - - - customer_visitor - last_visit_at - - - e - entity_id - - - - last_visit_at - - - e diff --git a/app/code/Magento/Customer/etc/indexer.xml b/app/code/Magento/Customer/etc/indexer.xml index 11471b4f6eb09..ccc24f0d6af9b 100644 --- a/app/code/Magento/Customer/etc/indexer.xml +++ b/app/code/Magento/Customer/etc/indexer.xml @@ -23,7 +23,6 @@ - diff --git a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml index 67bab36c9ccde..f684b89a329ca 100644 --- a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml +++ b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml @@ -257,18 +257,6 @@ - - - - Magento_Ui/js/grid/columns/date - dateRange - false - date - Last Logged In - 120 - - - From 73ef9f559f2888eaa7649686415faa7e89dceef5 Mon Sep 17 00:00:00 2001 From: Maxim Medinskiy Date: Thu, 17 Mar 2016 20:28:21 +0200 Subject: [PATCH 17/18] MAGETWO-47850: [WebAPI][GitHub] Customer is created even when validation is failed. --- .../CustomerRepository/TransactionWrapper.php | 52 ++++++++++++ .../TransactionWrapperTest.php | 85 +++++++++++++++++++ app/code/Magento/Customer/etc/di.xml | 3 + .../Customer/Api/CustomerRepositoryTest.php | 79 +++++++++++++++++ 4 files changed, 219 insertions(+) create mode 100644 app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php create mode 100644 app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php diff --git a/app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php b/app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php new file mode 100644 index 0000000000000..4820ff56d13ea --- /dev/null +++ b/app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php @@ -0,0 +1,52 @@ +resourceModel = $resourceModel; + } + + /** + * @param \Magento\Customer\Api\CustomerRepositoryInterface $subject + * @param callable $proceed + * @param \Magento\Customer\Api\Data\CustomerInterface $customer + * @param string $passwordHash + * @return \Magento\Customer\Api\Data\CustomerInterface + * @throws \Exception + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundSave( + \Magento\Customer\Api\CustomerRepositoryInterface $subject, + \Closure $proceed, + \Magento\Customer\Api\Data\CustomerInterface $customer, + $passwordHash = null + ) { + $this->resourceModel->beginTransaction(); + try { + /** @var $result \Magento\Customer\Api\Data\CustomerInterface */ + $result = $proceed($customer, $passwordHash); + $this->resourceModel->commit(); + return $result; + } catch (\Exception $e) { + $this->resourceModel->rollBack(); + throw $e; + } + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php new file mode 100644 index 0000000000000..f71d3184b5bc3 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php @@ -0,0 +1,85 @@ +resourceMock = $this->getMock('Magento\Customer\Model\ResourceModel\Customer', [], [], '', false); + $this->subjectMock = $this->getMock('Magento\Customer\Api\CustomerRepositoryInterface', [], [], '', false); + $this->customerMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false); + $customerMock = $this->customerMock; + $this->closureMock = function () use ($customerMock) { + return $customerMock; + }; + $this->rollbackClosureMock = function () use ($customerMock) { + throw new \Exception(self::ERROR_MSG); + }; + + $this->model = new \Magento\Customer\Model\Plugin\CustomerRepository\TransactionWrapper($this->resourceMock); + } + + public function testAroundSaveCommit() + { + $this->resourceMock->expects($this->once())->method('beginTransaction'); + $this->resourceMock->expects($this->once())->method('commit'); + + $this->assertEquals( + $this->customerMock, + $this->model->aroundSave($this->subjectMock, $this->closureMock, $this->customerMock, $this->saveOption) + ); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage error occurred + */ + public function testAroundSaveRollBack() + { + $this->resourceMock->expects($this->once())->method('beginTransaction'); + $this->resourceMock->expects($this->once())->method('rollBack'); + + $this->model->aroundSave($this->subjectMock, $this->rollbackClosureMock, $this->customerMock, $this->saveOption); + } +} diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index 03747e91db659..05e37bcc904f9 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -319,4 +319,7 @@ + + + diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php index 36af26d2dedbe..87e3484d554d7 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php @@ -6,12 +6,14 @@ namespace Magento\Customer\Api; use Magento\Customer\Api\Data\CustomerInterface as Customer; +use Magento\Customer\Api\Data\AddressInterface as Address; use Magento\Framework\Api\SortOrder; use Magento\Framework\Exception\InputException; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\Helper\Customer as CustomerHelper; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Framework\Webapi\Exception as HTTPExceptionCodes; +use Magento\Framework\Exception\NoSuchEntityException; /** * Test class for Magento\Customer\Api\CustomerRepositoryInterface @@ -346,6 +348,83 @@ public function testUpdateCustomerException() } } + /** + * Test creating a customer with absent required address fields + */ + public function testCreateCustomerWithoutAddressRequiresException() + { + $customerDataArray = $this->dataObjectProcessor->buildOutputDataArray( + $this->customerHelper->createSampleCustomerDataObject(), + '\Magento\Customer\Api\Data\CustomerInterface' + ); + + foreach ($customerDataArray[Customer::KEY_ADDRESSES] as & $address) { + $address[Address::FIRSTNAME] = null; + } + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH, + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'Save', + ], + ]; + $requestData = ['customer' => $customerDataArray]; + try { + $this->_webApiCall($serviceInfo, $requestData); + $this->fail('Expected exception did not occur.'); + } catch (\Exception $e) { + if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { + $expectedException = new InputException(); + $expectedException->addError( + __( + InputException::REQUIRED_FIELD, + ['fieldName' => Address::FIRSTNAME] + ) + ); + $this->assertInstanceOf('SoapFault', $e); + $this->checkSoapFault( + $e, + $expectedException->getRawMessage(), + 'env:Sender', + $expectedException->getParameters() // expected error parameters + ); + } else { + $this->assertEquals(HTTPExceptionCodes::HTTP_BAD_REQUEST, $e->getCode()); + $exceptionData = $this->processRestExceptionResult($e); + $expectedExceptionData = [ + 'message' => InputException::REQUIRED_FIELD, + 'parameters' => ['fieldName' => Address::FIRSTNAME], + ]; + $this->assertEquals($expectedExceptionData, $exceptionData); + } + } + + try{ + $this->customerRegistry->retrieveByEmail( + $customerDataArray[Customer::EMAIL], + $customerDataArray[Customer::WEBSITE_ID] + ); + $this->fail('An expected NoSuchEntityException was not thrown.'); + } catch (NoSuchEntityException $e) { + $exception = NoSuchEntityException::doubleField( + 'email', + $customerDataArray[Customer::EMAIL], + 'websiteId', + $customerDataArray[Customer::WEBSITE_ID] + ); + $this->assertEquals( + $exception->getMessage(), + $e->getMessage(), + 'Exception message does not match expected message.' + ); + } + } + /** * Test with a single filter */ From b5078f011a5ad9b3c0586084678d6402de6fad7e Mon Sep 17 00:00:00 2001 From: Maxim Medinskiy Date: Thu, 17 Mar 2016 21:53:46 +0200 Subject: [PATCH 18/18] MAGETWO-47850: [WebAPI][GitHub] Customer is created even when validation is failed. - fixed tests --- .../CustomerRepository/TransactionWrapperTest.php | 13 +++++++++---- .../Magento/Customer/Api/CustomerRepositoryTest.php | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php index f71d3184b5bc3..314ea794b4993 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php @@ -38,9 +38,9 @@ class TransactionWrapperTest extends \PHPUnit_Framework_TestCase protected $customerMock; /** - * @var bool + * @var string */ - protected $saveOption = true; + protected $passwordHash = true; const ERROR_MSG = "error occurred"; @@ -67,7 +67,7 @@ public function testAroundSaveCommit() $this->assertEquals( $this->customerMock, - $this->model->aroundSave($this->subjectMock, $this->closureMock, $this->customerMock, $this->saveOption) + $this->model->aroundSave($this->subjectMock, $this->closureMock, $this->customerMock, $this->passwordHash) ); } @@ -80,6 +80,11 @@ public function testAroundSaveRollBack() $this->resourceMock->expects($this->once())->method('beginTransaction'); $this->resourceMock->expects($this->once())->method('rollBack'); - $this->model->aroundSave($this->subjectMock, $this->rollbackClosureMock, $this->customerMock, $this->saveOption); + $this->model->aroundSave( + $this->subjectMock, + $this->rollbackClosureMock, + $this->customerMock, + $this->passwordHash + ); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php index 87e3484d554d7..93de33d765fdd 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php @@ -404,7 +404,7 @@ public function testCreateCustomerWithoutAddressRequiresException() } } - try{ + try { $this->customerRegistry->retrieveByEmail( $customerDataArray[Customer::EMAIL], $customerDataArray[Customer::WEBSITE_ID]