gpt4 book ai didi

magento - 在 magento head.phtml 中回显产品属性

转载 作者:行者123 更新时间:2023-12-05 01:09:44 24 4
gpt4 key购买 nike

我试图通过使用自定义属性在 Magento 中为产品设置我自己的自定义规范链接,但我无法在 head.phtml 文件中获得该属性。这是我到目前为止。请问有人可以帮忙吗?

<?php if (Mage::registry('current_product')) : ?>
<?php $customcanonical = Mage::registry(‘current_product’)->getData(‘canonical_link’); ?>
<link rel="canonical" content="<?php echo $customcanonical ?>" />
<?php endif; ?>

其中 canonical_link 是我的自定义属性

最佳答案

尝试这样的事情:

<?php if ($_product = Mage::registry('current_product')) : ?>
<?php $customcanonical = $_product->getData('canonical_link'); ?>
<?php if ($customcanonical): ?>
<link rel="canonical" content="<?php echo $customcanonical ?>" />
<?php endif; ?>
<?php endif; ?>

还要确保您的“canonical_link”属性在当前使用的属性集中,并且为您正在查看的当前产品指定了值。如果此属性或产品是新的(或者如果使用平面目录!),请确保您也重新索引。最后,如果您有缓存,请确保刷新它以显示新更改(或在开发新产品时禁用它)在登台环境或本地为您的网站添加功能。)

关于magento - 在 magento head.phtml 中回显产品属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15461061/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com