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

URL rewrites are not being generated when Single-Store Mode is enabled #25190

Closed
paul-blundell opened this issue Oct 21, 2019 · 15 comments
Closed
Assignees
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@paul-blundell
Copy link

paul-blundell commented Oct 21, 2019

Preconditions (*)

  1. Magento (Open Source) 2.3.3
  2. PHP 7.1.32
  3. MySQL 5.7.15

Steps to reproduce

  1. Ensure Single-Store Mode is disabled
  2. Change the store code and store view code so they are not default (unsure if this step is needed)
  3. Add a new product
  4. Edit product and in drop down change to your store view.
  5. Change product title
  6. Confirm all changes are reflected on the frontend.
  7. Enable Single-Store mode
  8. Change product title of previously created product, note how this doesn't change on frontend.
  9. Add a new simple product and specify a url_key
  10. Check the url_rewrite database table and search the request_path column for the url_key you entered.

Expected result

New URL key should be in the database table

Actual result

Nothing is updated in the database

Once I disable the Single-Store mode and repeat the steps. It works perfectly and the url_rewrite table is updated as soon as I save.

There seems to be an issue if you enable Single-Store mode after previously using multi-store mode and override values on a store level.

@m2-assistant
Copy link

m2-assistant bot commented Oct 21, 2019

Hi @paul-blundell. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@paul-blundell do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Oct 21, 2019
@paul-blundell paul-blundell changed the title URL Rewrites are not being generated when Single-Store Mode is enabled URL rewrites are not being generated when Single-Store Mode is enabled Oct 21, 2019
@paul-blundell
Copy link
Author

@magento give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @paul-blundell. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @paul-blundell, here is your Magento instance.
Admin access: https://i-25190-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@paul-blundell
Copy link
Author

paul-blundell commented Oct 21, 2019

I have been able to reproduce on the fresh instance of the develop branch. See my updated description for steps on how to reproduce.

I believe there is an underlying issue with Single-Store mode and others have reported similar issues: #5929

@engcom-Delta engcom-Delta self-assigned this Oct 23, 2019
@m2-assistant
Copy link

m2-assistant bot commented Oct 23, 2019

Hi @engcom-Delta. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Delta
Copy link
Contributor

Hi @paul-blundell thank you for your report. Unfortunately, I am not able to reproduce issue by steps you described on clean 2.3-develop.
#25190issue

If you'd like to update the issue, please reopen it.

@paul-blundell
Copy link
Author

@engcom-Delta Did you do step 4? With Single-Store mode set to No, did you change the scope to the store view, then edit & save the product. This is the critical step to reproducing this.

@engcom-Delta
Copy link
Contributor

@paul-blundell I did step 4. But I didn't experience issue with generating URL keys. Tested with Enable Single-Store Mode=No and Enable Single-Store Mode=Yes.
I noticed another issue: Product Name cannot be changed in Single-Store Mode if it was edited in store view level( Default Store View in my case). For this case you could create separate issue.

@cmbilisim
Copy link

I have same problem on magento 2.3.3 release.

Additionally when I changed auto generated url key, its add new record for url key

@shrma-smit
Copy link

@twoatechguy
Copy link

twoatechguy commented Jan 23, 2020

This is happening to me in 2.3.3 release as well. Quite unfortunate this bug with single store mode has gone on for years without resolution.

@victortodoran
Copy link

victortodoran commented Feb 27, 2020

\Magento\Catalog\Model\Product::getStoreIds() this is the method were things go south.
More specifically the following:
if ($this->_storeManager->isSingleStoreMode()) { $websiteIds = array_keys($websiteIds); }

It still happens on 2.2.3

@MatthijsBreed
Copy link

MatthijsBreed commented Mar 2, 2020

Can confirm @victortodoran 's comment

public function getStoreIds()
    {
        if (!$this->hasStoreIds()) {
            $storeIds = [];
            if ($websiteIds = $this->getWebsiteIds()) {
                if ($this->_storeManager->isSingleStoreMode()) {
                    $websiteIds = array_keys($websiteIds);
                }
                foreach ($websiteIds as $websiteId) {
                    $websiteStores = $this->_storeManager->getWebsite($websiteId)->getStoreIds();
                    // phpcs:ignore Magento2.Performance.ForeachArrayMerge
                    $storeIds = array_merge($storeIds, $websiteStores);
                }
            }
            $this->setStoreIds($storeIds);
        }
        return $this->getData('store_ids');
    }

When creating a new product with single-store mode enabled, $this->getWebsiteIds() returns an array [ 0 => "1" ], containing the main store as expected
Calling array_keys() makes this [ 0 => 0 ], the global scope, I don't know why Magento would do this

Magento\CatalogUrlRewrite\Model\ProductScopeRewriteGenerator::generateForGlobalScope doesn't generate rewrites this way, since the only store_id it gains is the global scope:

public function generateForGlobalScope($productCategories, Product $product, $rootCategoryId = null)
    {
        $productId = $product->getEntityId();
        $mergeDataProvider = clone $this->mergeDataProviderPrototype;

        foreach ($product->getStoreIds() as $id) {
            if (!$this->isGlobalScope($id) &&
                !$this->storeViewService->doesEntityHaveOverriddenUrlKeyForStore(
                    $id,
                    $productId,
                    Product::ENTITY
                )) {
                $mergeDataProvider->merge(
                    $this->generateForSpecificStoreView($id, $productCategories, $product, $rootCategoryId)
                );
            }
        }

        return $mergeDataProvider->getData();
    }

Commenting out the lines if ($this->_storeManager->isSingleStoreMode()) { $websiteIds = array_keys($websiteIds); } results in url-rewrites being properly generated for new products

@nadroj467
Copy link

I have experienced same issue in Magento 2.3.3 commenting the above line as mentioned by @MatthijsBreed resolved the issue for me. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

9 participants