Using Magento 2.3.2.
We currently sell through our website, and Amazon and Ebay via the M2E Pro extension. Our current product description is used for the website and Ebay, and the short description is used for Amazon.
The product description is not really suitable for the website, as it contains a lot of ebay related content, so I was wondering if it was possible to create a new attribute, say, 'web_description' and use that as the description on the website.
Any help in solving this problem would be greatly appreciated.
Thank you.
2 Answers 2
Add a new web_description attribute using admin.
Then in your custom theme, in Magento_Catalog/layout/catalog_product_view.xml, add the code below.
<referenceBlock name="product.info.description"><arguments><argument name="at_call" xsi:type="string">getWebDescription</argument> <argument name="at_code" xsi:type="string">web_description</argument> <argument name="css_class" xsi:type="string">web-description</argument></arguments></referenceBlock>
-
That actually seems a bit more straightforward than my solution.user355218– user3552182020年10月04日 07:25:51 +00:00Commented Oct 4, 2020 at 7:25
I found the answer on another post
/vendor/theme/magento_catalog/templates/product/view/attribute.phtml
$_call = $block->getAtCall();
if($_code == "description") {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
$storeCode = $storeManager->getStore()->getCode();
if($_code == "description") {
$_call = 'getWebsiteDescription' ;
$_code == "website_description";
}
}
$_className = $block->getCssClass();
$_attributeLabel = $block->getAtLabel();
$_attributeType = $block->getAtType();
$_attributeAddAttribute = $block->getAddAttribute();
Explore related questions
See similar questions with these tags.