想修改 Magento 产品详情页面 Details 和 More Information 标题文字。
首先需要确认是修改哪个文件:
包含 More Information 的文件
> cd /some_path/magento2/vendor/magento
> grep "More Information" -r .
./module-page-builder/view/frontend/page_layout/product-full-width.xml:
<argument name="title" translate="true" xsi:type="string">More Information</argument>
./module-page-builder/i18n/en_US.csv:
"More Information","More Information"
./module-catalog/view/frontend/layout/catalog_product_view.xml:
<argument translate="true" name="title" xsi:type="string">More Information</argument>
./module-catalog/view/frontend/templates/product/view/attributes.phtml:
<caption class="table-caption"><?= $block->escapeHtml(__('More Information')) ?></caption>
./module-catalog/i18n/en_US.csv:
"More Information","More Information"
大概率是修改这个文件:
./module-catalog/view/frontend/layout/catalog_product_view.xml
最后验证了一下,确实是这个文件。
应该搜索 HTML 代码
<a class="data switch scroll-reveal reveal-slide-in reveal-ready" tabindex="-1" data-toggle="trigger" href="#additional" id="tab-label-additional-title" style="--animation-order: 4;">
More Information
</a>
但是没有搜索到对应的修改点:
> grep "tab-label-additional-title" -r .
./module-catalog/Test/Mftf/Section/StorefrontProductMoreInformationSection.xml:
<element name="moreInformation" type="button" selector="#tab-label-additional-title" timeout="30"/>
./module-catalog/Test/Mftf/Section/StorefrontProductMoreInformationSection.xml:
<element name="moreInformationSectionToggleState" type="button" selector="//*[@id='tab-label-additional-title']/ancestor::div[@aria-selected='{{boolean}}'][@aria-expanded='{{boolean}}']" parameterized="true"/>
module-catelog/i18n/en_US.csv 与 module-page-builder/i18n/en_US.csv 的区别
- Catalog 商品目录管理
- Page Builder 可视化页面编辑
但跟这两个文件都没有关系,因为在这两个文件中找不到 Details 的翻译。说明不是这个文件。
vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml
<block class="Magento\Catalog\Block\Product\View\Details" name="product.info.details" template="Magento_Catalog::product/view/details.phtml" after="product.info.media">
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.description" as="description" template="Magento_Catalog::product/view/attribute.phtml" group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getDescription</argument>
<argument name="at_code" xsi:type="string">description</argument>
<argument name="css_class" xsi:type="string">description</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Details</argument> // 这里是 Details
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
<block class="Magento\Catalog\Block\Product\View\Attributes" name="product.attributes" as="additional" template="Magento_Catalog::product/view/attributes.phtml" group="detailed_info">
<arguments>
<argument translate="true" name="title" xsi:type="string">More Information</argument> // 这里是 More Information
<argument name="sort_order" xsi:type="string">20</argument>
</arguments>
</block>
</block>
还是需要就行这个文件。
修改生效
> php bin/magento cache:clean
> php bin/magento cache:flush
继续阅读 🌳
微信关注我哦 👍
我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式