Skip to content

Commit da44f0a

Browse files
ENGCOM-5228: #23053 : sendfriend verifies product visibility instead of status #23118
- Merge Pull Request #23118 from Wirson/magento2:23053-sendfriend-visibility-fix - Merged commits: 1. 265e0d4 2. 74373a0
2 parents 9473b31 + 74373a0 commit da44f0a

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

app/code/Magento/SendFriend/Controller/Product.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function __construct(
6161

6262
/**
6363
* Check if module is enabled
64+
*
6465
* If allow only for customer - redirect to login page
6566
*
6667
* @param RequestInterface $request
@@ -102,7 +103,7 @@ protected function _initProduct()
102103
}
103104
try {
104105
$product = $this->productRepository->getById($productId);
105-
if (!$product->isVisibleInCatalog()) {
106+
if (!$product->isVisibleInSiteVisibility() || !$product->isVisibleInCatalog()) {
106107
return false;
107108
}
108109
} catch (NoSuchEntityException $noEntityException) {

dev/tests/integration/testsuite/Magento/SendFriend/Controller/SendmailTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ public function testSendActionAsGuestWithInvalidData()
8585
);
8686
}
8787

88+
/**
89+
* Share the product invisible in catalog to friend as guest customer
90+
*
91+
* @magentoDbIsolation enabled
92+
* @magentoAppIsolation enabled
93+
* @magentoConfigFixture default_store sendfriend/email/enabled 1
94+
* @magentoConfigFixture default_store sendfriend/email/allow_guest 1
95+
* @magentoDataFixture Magento/Catalog/_files/simple_products_not_visible_individually.php
96+
*/
97+
public function testSendInvisibleProduct()
98+
{
99+
$product = $this->getInvisibleProduct();
100+
$this->prepareRequestData();
101+
102+
$this->dispatch('sendfriend/product/sendmail/id/' . $product->getId());
103+
$this->assert404NotFound();
104+
}
105+
88106
/**
89107
* @return ProductInterface
90108
*/
@@ -93,6 +111,14 @@ private function getProduct()
93111
return $this->_objectManager->get(ProductRepositoryInterface::class)->get('custom-design-simple-product');
94112
}
95113

114+
/**
115+
* @return ProductInterface
116+
*/
117+
private function getInvisibleProduct()
118+
{
119+
return $this->_objectManager->get(ProductRepositoryInterface::class)->get('simple_not_visible_1');
120+
}
121+
96122
/**
97123
* Login the user
98124
*

0 commit comments

Comments
 (0)