如果请求的网址用于简单产品,如何显示带有预选选项的可配置产品?
例如:
简单的产品#1 has:
Color: Red
URL: /simple-red.html
简单的产品#2 has:
Color: Green
URL: /simple-green.html
可配置产品 has:
URL: /config.html
如果用户访问/simple-red.html
它应该被加载可配置产品带有预先选择的选项Color: Red
如果用户访问/simple-green.html
它应该被加载可配置产品带有预先选择的选项Color: Green
成功解决问题:
-
扩展ProductController
,用父可配置产品的产品 ID 替换简单产品的产品 ID。使用过的SO答案:
Magento Catalog ProductController 重写 https://stackoverflow.com/a/18738934/3106547
自定义代码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];
}
}
...
根据简单产品预先选择可配置的产品选项。用过的链接到 Vishal Sharma 给出的教程 https://stackoverflow.com/a/23607355/3106547
Result(抱歉无法发布图片):截屏 https://dl.dropboxusercontent.com/u/55521820/shared/so-magento-simple-product-url.PNG
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)