Preselect configurable product options by simple product URL

ⅰ亾dé卋堺 提交于 2019-12-04 10:03:34
Elaman

Successfully solved the problem:

  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];
        }
    }
    ...
    
  2. PreSelect configurable product options depending on simple product. Used link to tutorial given by Vishal Sharma

Result (sorry can't post images): Screenshot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!