magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.55k stars 9.32k forks source link

Meta tags auto generation: variables cannot be used multiple times #35670

Open schnere opened 2 years ago

schnere commented 2 years ago

Preconditions and environment

Steps to reproduce

  1. Execute bin/magento config:set catalog/fields_masks/meta_keyword '{{name}}, order {{name}}' or set manually
  2. Login to Magento2 Backend
  3. Create a new product
  4. Set product name to "NEW PRODUCT"
  5. Check meta keywords

Expected result

The meta keywords should be set to NEW PRODUCT, order NEW PRODUCT

Actual result

The meta keywords are set to NEW PRODUCT, order {{name}} . So the second occurrence is not replaced as expected.

Additional information

I think the substitution is done here? https://github.com/magento/magento2/blob/1a7f152da7dca587e01e69012847e12cd86b75e3/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit.phtml#L198

So the solution would be to use replaceAll instead of replace:

var value = self._masks[this].replaceAll(self.varsRegexp, function(maskfieldName) {
    return $('#' + maskfieldName.slice(2, -2)).val();
});

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @schnere. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

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

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] commented 2 years ago

Hi @engcom-November. 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: :point_down:

engcom-November commented 2 years ago

Hi @schnere , Thank you for reporting and collaboration. Verified the issue on Magento 2.4-develop branch and is reproducible but however, this seems to be an expected behavior but not a bug. As per Magento docs1 and docs2, each meta keywords tag should be unique. No URLs should have the same meta keywords value. Any phrase that you want to include in every meta description, you can type the value directly into the appropriate field. Kindly provide reference documents / proofs that supports duplicating the same keyword for meta data to consider this as a valid bug. Thank you.

schnere commented 2 years ago

Hi @engcom-November ,

thanks for your reply. So the expected behavior if i use for example {{manufacturer}} {{name}} - {{manufacturer}} eCommerce would be the following output: Adobe Magento - {{manufacturer}} eCommerce ?

Why would someone use a variable twice not expecting it to get replaced twice?

In my opinion there are use cases to use a variable in meta tags more than once, for example as meta description: {{manufacturer}} {{name}} - Buy {{manufacturer}} products in our online store!

Furthermore I think that, if this might not be a use case for anyone, it would not be a problem to replace the variable more than once. So the fix is simple and will not cause problems for anyone, but would be a solution for some?

engcom-November commented 2 years ago

Hi @schnere , Thanks for your reply. Since its not clear in Magento official docs regarding the usage of placeholders for meta data we are considering this as a feature request. Thank you.