1

我有 Magento 多商店网站,我希望用户能够从所有网站将产品添加到他的购物车并支付一次。

我使用这篇文章成功地做到了。

但是当用户点击购物车中的产品时,他并没有被重定向到正确的网站。这是最后文章中描述的限制。

用于编辑购物车中项目的链接会将客户重定向到原始购物车网站。可以更改它,您可以覆盖购物车项目块的 getUrl 方法或覆盖控制器。

我找不到有关如何执行此覆盖的任何解释。

有人可以帮我做到这一点吗?

谢谢

4

1 回答 1

1

In my case i seen file of cart's item.phtml, it was using getproducturl(). So, I modified that method in file /app/code/core/Mage/Checkout/Block/Cart/Item/Renderer.php line 152. I made condition that if its main website don't change otherwise it adds stores code in url like www.example/store1/Producturl.

I hope This will Help You.

As You Require The File method. Check belowed code.

    public function getProductUrl()
        {
            if (!is_null($this->_productUrl)) {
                return $this->_productUrl;
            }
            if ($this->getItem()->getRedirectUrl()) {
                return $this->getItem()->getRedirectUrl();
            }

            $product = $this->getProduct();
            $option  = $this->getItem()->getOptionByCode('product_type');
            if ($option) {
                $product = $option->getProduct();
            }
            $webids = $product->getWebsiteIds();
            $wid = array();
            foreach($webids as $webid){
                $wid[] = $webid;
            }
            if(!in_array(1,$wid)){
                $website = Mage::app()->getWebsite($wid[0])->getCode();
                $org_url = $product->getUrlModel()->getUrl($product);
                $mod_url = str_replace("www.example.com/index.php/","www.example.com/".$website."/index.php/",$org_url);
                return $mod_url;
            }
            return $product->getUrlModel()->getUrl($product);
        }

As my first website id was "1", that's why i used in_array(1.$wid). You Can use your main website id over there. and in str_replace u can use baseurl() method of main website instead of static value i used.

于 2014-09-05T07:03:39.330 回答