Skip to content
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

Preview button causes user to log out #4

Open
D-Siedentopf-b3-it opened this issue Jul 11, 2024 · 1 comment
Open

Preview button causes user to log out #4

D-Siedentopf-b3-it opened this issue Jul 11, 2024 · 1 comment

Comments

@D-Siedentopf-b3-it
Copy link

The preview button in the product list and on the product detail page causes the user to log out if the product is assigned to another website than the main website. This happens because the URL that gets generated is wrong.

Preview URL for a product assigned to the main website which works: https://xxx/german/product1.html
Preview URL for a product assigned to another website which does not work: https://xxx/german/admin/catalog/product/view/id/2418/s/product2/key/b6ea7526976d44ec385f0cca39e5abc773a432a99029b9aff40c12785d2422fc/

@Hanmac
Copy link

Hanmac commented Jul 18, 2024

I think the problem might be this:

$storeId    =  (int)$this->context->getRequestParam('store');
if (!$storeId) {
    $storeManager = \Magento\Framework\App\ObjectManager::getInstance()
        ->create(\Magento\Store\Model\StoreManagerInterface::class);
    $storeId = $storeManager->getDefaultStoreView()->getId();
}
$previewUrl = $previewProduct->setStoreId($storeId)->getUrlModel()->getUrlInStore($previewProduct, ['_escape' => true]);

I don't think the store parameter is passed through when using a Product that is assigned to a different store.

So storeId gets set to the default store view,
but then, getUrlInStore fails because that Product is not available in default store?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants