-
Notifications
You must be signed in to change notification settings - Fork 340
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
Make use of display_pattern on Product Frontend View #3039
Conversation
Hello @ecrocombe, I wouldn't go the way of a block override, considering Could you re-implement this with an "after" plugin ? Instead of looping again on the list of product attributes, though, I would probably inject an attribute collection allowing to get the list of attributes for that product that are
Also, considering not everyone would want the feature enabled by default, could you add a Yes/No store configuration setting somewhere below smile_elasticsuite_catalogsearch_settings/catalogsearch ? Regards, |
Hello @rbayet I will look into using a plugin. I did consider having a configuration yes/no for this, however by setting the
is, in its own right, a yes/no configuration? although, not store scoped. Please correct me if I'm wrong, it's currently enabled by default on the layered navigation, and I cannot come up with a scenario where a user would want it in layered navigation but not on product page? I'm also working on this for the product compare page, can anyone think of somewhere else on the frontend where display_pattern should be used? |
Yes, I guess but the point of making it store scoped is to allow a Magento admin to answer both the question
That last part was to answer your question in the issue about
Because people could have already taken the matter in their own hands and have some pre-existing customization to handle unit display.
And considered that, on the product page, where the attributes are displayed, having the attribute label "Weight (kg)" is enough. Since we are introducing something that is not essentially search and navigation related, we're walking a bit outside of our own territory, so I would prefer it to not affect any pre-existing behavior by default.
Regards |
Thank you for taking the time and clearing that up for me, I will go back to the drawing board and add your suggested changes. |
Ready for review/approval |
Hello @ecrocombe, Thanks for updating the PR. Regards |
I have cleaned this up as much as I can, the remaining errors say they can be auto fixed? Mainly having trouble with the combination of these 3 rules AND the use of coalescing on multiple lines, They seem to conflict each other making a solution impossible, at least to my best abilities.
|
Hello @ecrocombe, Let me check the remaining rules and get back to you with a solution. Regards, |
src/module-elasticsuite-catalog/Plugin/Catalog/Product/View/AttributesPlugin.php
Outdated
Show resolved
Hide resolved
Hello @ecrocombe, Please find the suggestions above. Regards, |
Thank you @rbayet for walking me through this PR. If you haven't already noticed, this is my first contribution to a Git project, and I appreciate the time you have taken to educate me. All the best, |
Hmmm... something strange happened locally. |
OK @ecrocombe, that's weird, I rebased your branch locally on top of 2.11.x and squashed the commit, but I mistakenly (force) pushed this repository 2.11.x on top of you 2.11.x branch. |
If you want @ecrocombe, you can
You'll be able to create a new PR with the same code as #3047 but get the badge once I merge it. Regards, |
implementation of #3038
1: Change the attribute display value available to the template
Override Class Method
Magento\Catalog\Block\Product\View\Attributes::getAdditionalData
and add :elseif (is_numeric($value) && str_contains($attribute->getData('display_pattern') ?? '','%s')){
$value = sprintf($attribute->getData('display_pattern'),$value);
}
2: Use newly created block in product view page
Reference existing Block class and change to new block class
<referenceBlock name="product.attributes" class="Smile\ElasticsuiteCatalog\Block\Product\View\Attributes"/>
NOTE: I don't believe that
#2
is the correct way about using the new block class. I tried to create a preference in bothdi.xml
andfrontend/di.xml
(<preference for="Magento\Catalog\Block\Product\View\Attributes" type="Smile\ElasticsuiteCatalog\Block\Product\View\Attributes"/>
) but it didn't work, I'm not sure if this is my installation or not.