Skip to content

Commit 265e0d4

Browse files
committed
#23053 : sendfriend verifies product visibility instead of status
1 parent 98703f6 commit 265e0d4

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected function _initProduct()
102102
}
103103
try {
104104
$product = $this->productRepository->getById($productId);
105-
if (!$product->isVisibleInCatalog()) {
105+
if (!$product->isVisibleInSiteVisibility() || !$product->isVisibleInCatalog()) {
106106
return false;
107107
}
108108
} 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)