-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Specify Magento_Catalog
module on template for sorting
#1385
Conversation
Can't you just use |
Such "redundant" declarations is used on mostly all the blocks in Catalog layout update and this one in particular looks like a black sheep to me. One of the reasons I wanted this was for uniformity. |
The fact such prefix is present in some declarations does not mean it's the right thing to do. For uniformity it could be simply stripped out for all places where it does not change system behavior. Do the |
During exercises in the recent Magento 2 developer training some developers had a very similar experience. It was confusing that changing a block via preferences caused the rendering to break if the prefix on the template wasn't specified. I think it would help the allover expressiveness of the code and ease of development if the prefix where always specified. |
I'm trying to do the |
Not knowing your code, the |
@Vinai As I wrote on my initial post:
As @orlangur suggested, I'm trying to do the |
Sure, I understand. I'm just chiming in here to express my opinion that based on my experience during the Magento 2 dev training, it would be a good idea to always add the module name prefix to templates declarations in layout XML. It would make the view layer work more like what developers expect, that is, less surprising in case of a |
I'm totally with you in this idea. Thanks for the support. Any idea on my problem?
|
No idea without seeing your code. Can't promise I'll have time to test locally, even if you add it here though. But I might :) |
@vernard, this is surely an approach I would like to avoid, but if adding |
Ok, now I see, need to change both |
@orlangur By "initial declaration", do you mean block declaration in |
@vernard, yep. |
@vernard thank you for the contribution! We are going to accept this PR. However, I suggest you to replace Internal reference: MAGETWO-39816 |
@vernard Can you please merge it with the latest code? |
If the block `Magento\Catalog\Block\Product\ProductList\Toolbar` is rewritten in another module, it is searching for the template in that module, not in `Magento_Catalog`.
@vrann Done. |
@vernard, your contribution is added to 1.0.0-beta. This PR was not closed automatically by GitHub due to unknown reason, but your commit is available in history. Can we close this PR? |
Sure. Thanks for your help |
[firedrakes] MAGETWO-71231: Remove AR code from 2.2.0
I am trying to create an extension that enhances the sort order on product lists.
Problem
To extend the sorting feature, I had extend the block
Magento\Catalog\Block\Product\ProductList\Toolbar
. Without specifying that the template is onMagento_Catalog
, the module that extends this block also needs a copy of the template.What I tried
First, I tried using a plugin for this block and adding an
afterSetCollection()
method.Unfortunately, my plugin did not work. This block had no interceptor (I am still interested in this and open to answers why).
So, I did a rewrite using
<preference>
tag, then I made my changes in the block class from my module. After this, the toolbar was gone from the frontend! That is because it is searching for the template file (in my module) and not found. I worked it around by copying theproduct/list/toolbar.phtml
file on my module.