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

\Magento\Catalog\Model\Resource\Product\Collection method to set $needToAddWebsiteNamesToResult #1862

Closed
michsk opened this issue Sep 12, 2015 · 5 comments
Assignees

Comments

@michsk
Copy link

michsk commented Sep 12, 2015

I would like to suggest a method to set the $needToAddWebsiteNamesToResult property of \Magento\Catalog\Model\Resource\Product\Collection. I could work around it trough a Plugin and change the logic of the load() method in that collection, but would be easier if we could just set that value.

@michsk
Copy link
Author

michsk commented Sep 12, 2015

And personally it would be better fit for me if you would make doAddWebsiteNamesToResult public.

@michsk
Copy link
Author

michsk commented Sep 15, 2015

What is the reason that this adding the names of the websites is in the load()? https://github.com/magento/magento2/blob/develop/app/code/Magento/Catalog/Model/Resource/Product/Collection.php#L735

Very problematic, because there doesnt seem to be a way to override this, even with a plugin. Because when you do a afterLoad plugin, and than want to change the added products in the collection, you have to loop trough the collection which again calls the load method, and that again calls the afterLoad plugin... i have tried settings flags etcetc but im out of ideas on how to override this little method which adds the names to the product.

@michsk
Copy link
Author

michsk commented Sep 15, 2015

One way which seems to be helpfull is to find what calls $collection->addWebsiteNamesToResult() that makes it even more important to have that addWebsiteNamesToResult method public or atleast have a event on it, so we can alter this information.

For now i will try to have plugins that change the methods which call addWebsiteNamesToResult

@michsk
Copy link
Author

michsk commented Sep 16, 2015

Additionally, what magic are we using to call the protected addWebsiteNamesToResult() from AddWebsitesFieldToCollection class. Because that method is protected i didn't initially think about looking for other objects calling that class.

@BingQiangChen
Copy link

very useful!

@vkorotun vkorotun removed the MX label Aug 4, 2016
@michsk michsk closed this as completed Aug 16, 2016
magento-team pushed a commit that referenced this issue Dec 19, 2017
Public Pull Requests
#11618 Re saving product attribute [backport 2.1] by @raumatbel
#12611 Backport #4958 to 2.1 by @slackerzz

Fixed Public Issues
#6770 M2.1.1 : Re-saving a product attribute with a different name than it's code results in an error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants