Skip to content

#23053 : sendfriend verifies product visibility instead of status #23118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/code/Magento/SendFriend/Controller/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function __construct(

/**
* Check if module is enabled
*
* If allow only for customer - redirect to login page
*
* @param RequestInterface $request
Expand Down Expand Up @@ -102,7 +103,7 @@ protected function _initProduct()
}
try {
$product = $this->productRepository->getById($productId);
if (!$product->isVisibleInCatalog()) {
if (!$product->isVisibleInSiteVisibility() || !$product->isVisibleInCatalog()) {
return false;
}
} catch (NoSuchEntityException $noEntityException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
*
Expand Down