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

Category\Collection::joinUrlRewrite should use the store set on the collection #13704

Closed
alepane21 opened this issue Feb 17, 2018 · 5 comments
Closed
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line improvement Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@alepane21
Copy link
Contributor

Preconditions

  1. Magento 2.1.8
  2. PHP 7
  3. MySQL 5.6

Steps to reproduce

$categoryCollection = $this->categoryCollectionFactory->create();
$categoryCollection->setStoreId(1);
$categoryCollection->addUrlRewriteToResult();
echo $categoryCollection->getUrl();

Expected result

  1. should return the url of category in store 1

Actual result

  1. Instead it returns the url of default store

The problem is that Magento\Catalog\Model\ResourceModel\Category\Collection::joinUrlRewrite always use the store id from the store manager. I think that it should instead use the storeId set on the actual collection.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Feb 17, 2018
@orlangur
Copy link
Contributor

Hi @alepane21, from method implementation

public function getStoreId()
    {
        if ($this->_storeId === null) {
            $this->setStoreId($this->_storeManager->getStore()->getId());
        }
        return $this->_storeId;
    }

it looks like proposed change could be applied safely.

Could you please prepare a pull request containing suggested change and appropriate test?

@alepane21
Copy link
Contributor Author

I'm working on it.

@alepane21
Copy link
Contributor Author

If the pull request pass on develop-2.2 I'm also going to do the backport to 2.1-develop.

@magento-engcom-team
Copy link
Contributor

Hi @alepane21. Thank you for your report.
The issue has been fixed in #13716 by @alepane21 in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.5 release.

@magento-engcom-team
Copy link
Contributor

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label May 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line improvement Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

3 participants