通过简单的产品URL预选可配置的产品选项 [英] Preselect configurable product options by simple product URL

查看:80
本文介绍了通过简单的产品URL预选可配置的产品选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果请求的网址是简单产品,如何显示带有预选选项的可配置产品?

How to show configurable product with preselected options if requested url is for simple product?

例如:

For example:

简单产品#1 具有:
颜色: Red
URL: /simple-red.html

Simple product #1 has:
Color: Red
URL: /simple-red.html

简单产品#2 具有:
颜色:Green
URL: /simple-green.html

Simple product #2 has:
Color: Green
URL: /simple-green.html

可配置产品具有:
URL: /config.html

Configurable product has:
URL: /config.html

如果用户访问/simple-red.html,则应使用预先选择的选项颜色: Red

If user visits /simple-red.html it should be loaded configurable product with pre-selected option Color: Red

如果用户访问/simple-green.html,则应使用预先选择的选项颜色: Green

If user visits /simple-green.html it should be loaded configurable product with pre-selected option Color: Green

推荐答案

成功解决了该问题:

  1. 扩展了ProductController,用父级可配置产品的产品ID替换简单产品的产品ID.二手SO答案:
    重写Magento目录ProductController

    自定义ProductController:

  1. Extended ProductController, to replace product id of simple product by product id of parent configurable product. Used SO Answer:
    Magento Catalog ProductController rewrite

    Code in custom ProductController:

...
$productId  = (int) $this->getRequest()->getParam('id');

// Get parent configurable product
$_product = Mage::getModel('catalog/product')->load($productId);
if ($_product->getTypeId() == "simple") {
    $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($_product->getId());

    // If parent exists
    if (isset($parentIds[0])) {
        $productId = $parentIds[0];
    }
}
...

  • PreSelect可配置产品选项,具体取决于简单产品.使用链接到Vishal Sharma给出的教程

  • PreSelect configurable product options depending on simple product. Used link to tutorial given by Vishal Sharma

    结果(抱歉,无法发布图片): 屏幕截图

    Result (sorry can't post images): Screenshot

    这篇关于通过简单的产品URL预选可配置的产品选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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