【问题标题】:Preselect configurable product options by simple product URL通过简单的产品 URL 预选可配置的产品选项
【发布时间】:2014-05-12 10:52:13
【问题描述】:

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

例如:

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

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

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

如果用户访问/simple-red.html,它应该被加载可配置的产品 预选选项颜色: Red

如果用户访问/simple-green.html,它应该被加载可配置的产品 预选选项颜色: Green

【问题讨论】:

  • 你能解释一下吗?
  • @RaviChomal 通过添加示例更新问题
  • \js\varien\configurable.js 在此文件中的第 303 行中,您将在此处更改以执行此功能。

标签: magento magento-1.7 configurable-product


【解决方案1】:

成功解决问题:

  1. 扩展ProductController,用父可配置产品的产品ID替换简单产品的产品ID。使用 SO 答案:
    Magento Catalog ProductController rewrite

    自定义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];
        }
    }
    ...
    
  2. 根据简单产品预先选择可配置的产品选项。已使用link to tutorial given by Vishal Sharma

结果(抱歉无法发布图片): Screenshot

【讨论】:

  • 教程的链接在哪里?您提供的链接没有做任何事情。
猜你喜欢
  • 1970-01-01
  • 2014-09-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-07
  • 2011-04-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多