【问题标题】:Magento wrong language in wishlist愿望清单中的 Magento 语言错误
【发布时间】:2013-04-16 11:40:16
【问题描述】:

我对 magento 愿望清单有疑问。我的商店有 4 种不同的语言 (DE/EN/FR/IT)。 一切都很好,但在愿望清单中,无论商店语言是否设置为英语、法语等,产品名称和描述都以错误的语言(意大利语)显示。 我知道这里有一个类似的线程 Magento Not Translating Wishlist Product Name and Description

但删除$product = $this->_getData('product'); 的建议并不能解决问题。它仅将产品名称和描述更改为默认语言,即德语。

//解决方案//

我终于明白了。我知道这不是最完美的解决方案,但它确实有效。 在/app/code/core/Mage/Wishlist/Model/Item.php public function getProduct() 我删除了这一行 $product = $this->_getData('product'); 并添加了以下内容:

$store_id = Mage::app()->getStore()->getStoreId();

然后我改了:$product = Mage::getModel('catalog/product') ->setStoreId($this->getStoreId()) ->load($this->getProductId()); 到:

$product = Mage::getModel('catalog/product')
            ->setStoreId($store_id)
            ->load($this->getProductId());

【问题讨论】:

    标签: magento


    【解决方案1】:

    感谢您的解决方案。为避免多次重新加载产品,我已将该代码更改为:

    public function getProduct() {
    $product = null;
    $current_store_id = Mage::app()->getStore()->getStoreId();
    
    if (!$this->getProductId()) {
        Mage::throwException(Mage::helper('wishlist')->__('Cannot specify product.'));
    }
    
    if($this->_getData('last_store_id') != $current_store_id){
        $product = Mage::getModel('catalog/product')
        ->setStoreId($current_store_id)
        ->load($this->getProductId());
    } else {
        $product = $this->_getData('product');
    }
    
    $this->setData('product', $product);
    $this->setData('last_store_id', $current_store_id);
    
    /**
     * Reset product final price because it related to custom options
    */
    $product->setFinalPrice(null);
    $product->setCustomOptions($this->_optionsByCode);
    return $product;}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多