From 265e0d4e7ca2bc051652241020a1609e48523f72 Mon Sep 17 00:00:00 2001 From: Wirson Date: Tue, 4 Jun 2019 12:51:45 +0200 Subject: [PATCH 1/2] #23053 : sendfriend verifies product visibility instead of status --- .../Magento/SendFriend/Controller/Product.php | 2 +- .../SendFriend/Controller/SendmailTest.php | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/SendFriend/Controller/Product.php b/app/code/Magento/SendFriend/Controller/Product.php index 732bcef8b957a..388fcd23c2e0a 100644 --- a/app/code/Magento/SendFriend/Controller/Product.php +++ b/app/code/Magento/SendFriend/Controller/Product.php @@ -102,7 +102,7 @@ protected function _initProduct() } try { $product = $this->productRepository->getById($productId); - if (!$product->isVisibleInCatalog()) { + if (!$product->isVisibleInSiteVisibility() || !$product->isVisibleInCatalog()) { return false; } } catch (NoSuchEntityException $noEntityException) { diff --git a/dev/tests/integration/testsuite/Magento/SendFriend/Controller/SendmailTest.php b/dev/tests/integration/testsuite/Magento/SendFriend/Controller/SendmailTest.php index a075398e9cdb7..f5851a55d760a 100644 --- a/dev/tests/integration/testsuite/Magento/SendFriend/Controller/SendmailTest.php +++ b/dev/tests/integration/testsuite/Magento/SendFriend/Controller/SendmailTest.php @@ -85,6 +85,24 @@ public function testSendActionAsGuestWithInvalidData() ); } + /** + * Share the product invisible in catalog to friend as guest customer + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture default_store sendfriend/email/enabled 1 + * @magentoConfigFixture default_store sendfriend/email/allow_guest 1 + * @magentoDataFixture Magento/Catalog/_files/simple_products_not_visible_individually.php + */ + public function testSendInvisibleProduct() + { + $product = $this->getInvisibleProduct(); + $this->prepareRequestData(); + + $this->dispatch('sendfriend/product/sendmail/id/' . $product->getId()); + $this->assert404NotFound(); + } + /** * @return ProductInterface */ @@ -93,6 +111,14 @@ private function getProduct() return $this->_objectManager->get(ProductRepositoryInterface::class)->get('custom-design-simple-product'); } + /** + * @return ProductInterface + */ + private function getInvisibleProduct() + { + return $this->_objectManager->get(ProductRepositoryInterface::class)->get('simple_not_visible_1'); + } + /** * Login the user * From 74373a005e6c018b691fcbf3191862d9960bc624 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Thu, 6 Jun 2019 22:30:47 -0500 Subject: [PATCH 2/2] Fixed code style issue --- app/code/Magento/SendFriend/Controller/Product.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/SendFriend/Controller/Product.php b/app/code/Magento/SendFriend/Controller/Product.php index 388fcd23c2e0a..a184d7d8bff62 100644 --- a/app/code/Magento/SendFriend/Controller/Product.php +++ b/app/code/Magento/SendFriend/Controller/Product.php @@ -61,6 +61,7 @@ public function __construct( /** * Check if module is enabled + * * If allow only for customer - redirect to login page * * @param RequestInterface $request