在 Magento 中输出属性值和文本以及价格

发布于 2024-10-01 03:29:20 字数 512 浏览 3 评论 0原文

嗨,

我对 Magento 很陌生,对整个 css、php 也很陌生。我已经搜索了一个多月才找到这个答案(我确信它在某个地方,但我似乎找不到它)

我正在为一家服装公司建立一个 B2B 网站。由于他们是批发商,所以他们不出售单件商品,而是打包出售。根据商品的不同,有些会以 2 小号装;有些则以 2 小号装。 2-中; 2 个大号,其他将装在 1 个小号的包装中; 2-中; 1-大,等等。

到目前为止,我设置了一个名为“Package Set”的属性,它描述了客户在订购商品时将获得的包装类型,但它只出现在“附加信息”选项卡中,这不好,因为我们需要该信息脱颖而出。将其放在简短描述中是一种选择,但我们想更多地强调它。

所以我们想要 1. 在价格后面添加“每包”文字。 2. 在价格的正下方添加“套餐套装”属性的值,这样人们在类别和产品页面上都会清楚地看到它。它看起来像

“每包 60 美元”

套装:2 个小号; 2-中; 2-大号。”

我正在使用现代主题 运行 1.4.1.1

谢谢

HI

I am new to Magento and still new to the whole css, php thing. And I have been searching for over a month to find this answer (I am sure it is here some place, but I cannot seem to find it)

I am building a b2b site for a clothing company. Since they are a wholesaler, they do not sell single items, but rather, they sell them in a pack. Depending on the items , some will come in a pack of 2-Small; 2-Medium; 2-Large, other will come in a pack of 1-Small; 2-Medium; 1-Large, and so on.

So far, I set up an attribute called “Package Set”, which describes the kind of pack the customer will be getting when ordering the item, but it only appears in the Additional Information tab, which is not good, because we want that information to stand out. Putting it in the Short Description is an option, but we want to emphasize it more.

So we want to
1. add a text “per pack” right behind the price.
2. add the value of the attribute “Package Set”, right underneath the price, so people will see it clearly, both in the category and product page. It would look some thing like,

“$60 per pack

Package Set: 2-Small; 2-Medium; 2-Large.”

I am using the modern theme
running 1.4.1.1

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇柔作态 2024-10-08 03:29:20

将文件“app/code/design/frontend/base/default/template/catalog/product/view/price_clone.phtml”复制到目录“app/code/design/frontend/default/modern/template/catalog/product/”看法/”。这样您就不会覆盖原始文件。

打开文件进行编辑。在您看到此内容之后:

<?php echo $this->getPriceHtml($_product, false, '_clone') ?>

添加以下内容:

<?php echo $this->__('per pack') ?>

通过使用函数 $this->__() 您可以轻松翻译文本。始终这样做是一个很好的做法。

对于第二部分,现在在以下行中添加此位:

<p><?php echo $this->__('Package Set %s', $_product->getPackageSet()) ?></p>

再次,它可能会被翻译,但这次您的额外属性将插入到 %s 的位置。这样做的原因是为了在使用内联翻译。该行已被包裹在

段落标记中,以便更加清晰,并确保它出现在自己的行上,而不是在上一行的末尾。
我假设您的属性具有代码“product_set” - 在 Magento 中变为“camel case”,或 getProductSet

最后,您可能希望从“附加信息”选项卡中删除该属性。这很简单,返回管理中的“管理属性”页面,编辑您的属性并将“在前端的产品视图页面上可见”更改为“否”。

Copy the file "app/code/design/frontend/base/default/template/catalog/product/view/price_clone.phtml" to the directory "app/code/design/frontend/default/modern/template/catalog/product/view/". This is so you are not overwriting the original file.

Open the file for editing. After where you see this:

<?php echo $this->getPriceHtml($_product, false, '_clone') ?>

Add the following:

<?php echo $this->__('per pack') ?>

By using the function $this->__() you are making the text available to be translated easily. It is good practice to do this always.

For the second part now add this bit on the line after:

<p><?php echo $this->__('Package Set %s', $_product->getPackageSet()) ?></p>

Again it is potentially being translated but this time your extra attribute is being inserted where it says %s. The reason for doing this is to make it clearer when using inline translation. The line has been wrapped in a <p> paragraph tag for yet more clarity and to ensure it appears on it's own line, not following on the end of the previous.
I have assumed your attribute has the code "product_set" - which in Magento becomes 'camel case', or getProductSet.

Finally you might want to remove the attribute from Additional Information tab. This is quite simple, go back to the Manage Attributes page in admin, edit your attribute and change "Visible on Product View Page on Front-end" to "No".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文