从分层导航中预先选择可配置的产品选项 [英] Getting configurable product options pre selected from the layered navigation

查看:41
本文介绍了从分层导航中预先选择可配置的产品选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几种可配置的产品(有许多与之相关的简单产品).

I have several configurable products (with many simple products associated to them).

通过分层导航浏览超级属性时,您可以过滤出所有具有(例如)size =中,Color =红色的产品.

When browsing the super attributes through the layered navigation, you can filter down to all products that have (for instance) size= medium, Colour = Red.

我已将我的简单产品设置为不可见并显示我的可配置产品,但是,当您选择可配置产品时,产品选项不会默认为分层导航中已过滤的产品.

I have set my simple products to not be visible and showing my configurable products, however, when you select the configurable product, the product options do not default to what has been filtered in the layered navigation.

有没有办法在产品页面上预先选择相关的产品选项?

Is there a way to get the relevant product options pre-selected on the product page?

假设用户从列表页面选择过滤器,大小为="medium" color ="red"

suppose the user selected the filters from the listing page as size ="medium" colour ="red"

现在,当用户在应用过滤器后从列表页面选择可配置产品时,必须在产品详细信息页面上预先选择相应的值.

Now when user selects the configurable product from listing page after applying filter corresponding values must be pre selected on product detail page.

推荐答案

没有现成的方法可以做到这一点.当对产品提出请求时,该产品对分层导航状态一无所知.从理论上讲,您可以添加一些服务器端代码来执行此操作,但是这可能会降低性能,因为您可能无法有效使用缓存.

There is no ready-made way to do this. When the request is made for the product that product knows nothing of the layered navigation state. In theory you could add in some server side code to do that however this might have a performance penalty as you might not be able to use cache effectively.

您可以使用javascript在前端进行操作.将事件侦听器添加到过滤的导航中的链接,并将对象存储在本地存储中,例如大小和颜色.

You could do something on the front end in javascript. Add an event listener to the links in the filtered navigation and store an object in local storage, e.g. with size and colour.

然后在产品页面上,可以通过等待构建可配置产品选项来根据这些值设置可配置产品,然后从本地存储中加载选项对象,然后相应地更新可配置产品.然后,您需要触发事件,以便产品页面知道已选择了选项,并可以执行相应的操作,例如更新价格.

On the product page you could then set the configurable product according to those values by waiting for the configurable product options to be built, then load the options object from local storage and then update the configurable product accordingly. You will need to then fire off events so the product page knows that options have been selected and can do things like update the price accordingly.

Magento内部使用具有数字ID的属性选项值.使用这些可能会有些复杂,因此您可能需要添加一些逻辑来读取标签,例如'红色'而不是例如'461'.

Internally Magento uses attribute option values that have numerical ids. These can be a bit complicated to work with, so you may want to put some logic in to read the labels instead, e.g. 'Red' instead of e.g. '461'.

没有用于本地存储的特定于原型的方法,您不需要jquery层,在存储/检索大小/颜色对象时,普通的javascript就足够了.

There is no prototype specific way of working with local storage and you don't need some layer of jquery, normal javascript should suffice when it comes to storing/retrieving your size/colour object.

我发现以下文章是使用可配置产品下拉菜单进行操作所需的起点:

I found the following article to be the head start needed for doing things with the configurable product drop-downs:

http ://inchoo.net/ecommerce/magento/how-to-make-configurable-options-autoselected-on-configurable-product-view-page/

这篇关于从分层导航中预先选择可配置的产品选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆