如何直接链接到属性集?

发布于 2024-08-16 04:26:51 字数 723 浏览 3 评论 0原文

我已经创建了属性; “按类型选购”和“按颜色选购”。它们在分层导航和扩展搜索中效果很好。我设计了图形并将其放置在主页中,并希望链接到相应属性的指定产品。一直在网上搜索,但到目前为止还没有成功。

如果没有直接可行的方法,下一个方法是创建 cms 页面并直接链接到它。如何显示分配给特定属性的产品?特别是“多选”类型。

我知道你们至少更喜欢一些尝试,但正如前面提到的,一直在尝试但没有运气。我希望有某种起点。

节日快乐!

编辑:我能够将这段代码放在一起,列出分配给所述类别 ID 的所有产品。尝试对其进行过滤,仅显示具有指定相同属性的产品,但还没有成功。有什么想法吗?

<?php
$cat_id = 123; // category id
$category = Mage::getModel('catalog/category')->load($cat_id);

$_products = $category->getProductCollection()
->addAttributeToSelect('shop_by_color');

if (($this->getProductCollection()) && $_products->getSize()): ?>

顺便说一下,$cat_id 是 root 的子类别。有没有更简单的方法来指向它而不是直接使用 ID 号?

I have created attributes; “Shop by Type” and “Shop by Color”. They work great within the layered navigation and extended search. I’ve designed graphics and placed them in the home page and would like to link to the respective attribute’s assigned products. Been searching the webs, but so far have been unsuccessful.

If there’s no direct possible way, the next method would be creating cms pages and linking to it directly. How can I display products that are assigned to a specific attribute? Specifically “Multiple Select” types.

I know you guys prefer at least some attempts, but as mentioned, been playing with it with no luck. I would appreciate some kind of starting point.

Happy Holidays!

Edit: I was able to put together this code that lists all the products assigned to said category id. Tried to filter it down where it only displays products that have an assigned same attribute with no luck yet. Any ideas?

<?php
$cat_id = 123; // category id
$category = Mage::getModel('catalog/category')->load($cat_id);

$_products = $category->getProductCollection()
->addAttributeToSelect('shop_by_color');

if (($this->getProductCollection()) && $_products->getSize()): ?>

By the way, $cat_id is a sub category of root. Is there an easier way to point to it instead of using direct id number?

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

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

发布评论

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

评论(1

掐死时间 2024-08-23 04:26:52

我不知道这是否是您正在寻找的确切答案,但您应该更改

$_products = $category->getProductCollection()->addAttributeToSelect('shop_by_color');

$_products = $category->getProductCollection()
->addAttributeToSelect('shop_by_color')
->addAttributeToFilter(array('attribute'=>'shop_by_color', 'in'=>array('red', 'blue', ...)));

,以便它仅列出 shop_by_color 是给定常量之一的产品。您可以从 url 路径或查询字符串中获取这些内容,然后获得动态页面的基础,仅显示与其中一种输入颜色匹配的产品。

I don't know if that's the exact answer you're looking for, but you should change

$_products = $category->getProductCollection()->addAttributeToSelect('shop_by_color');

to

$_products = $category->getProductCollection()
->addAttributeToSelect('shop_by_color')
->addAttributeToFilter(array('attribute'=>'shop_by_color', 'in'=>array('red', 'blue', ...)));

so that it lists only product where their shop_by_color is one of the given constant. It's up to you to get those out of the url path or query string and you get your base for dynamic pages showing only products matching one of the input colors.

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