0

私のmagentoストアには3つの言語があります。たとえば、誰かが「英語」のストア ビューの製品をリンクしてくれて、私が「スペイン語」のストア ビューを表示している場合、その製品は 404 エラーを返します。

これまでの調査で、このブログを見つけましたが、現在、そのコードがどこにあるのかを理解しようとしています。ファイル内にあることは理解しています/app/code/core/Mage/Core/Model/Url/Rewrite.phpが、そのファイルのどこにそのコード スニペットを追加する必要があるのか​​ わかりません。

そして、それが私の問題を解決するかどうかさえ確信が持てません。

編集:

わかりました、次のリンクを見つけました: http://freegento.com/doc/db/d5d/_url_2_rewrite_8php-source.html

これによると、私のファイルには上記のブログで見たものと似たものが含まれているはずですが、残念ながら、loadByRequestPath私のファイルの機能は異なり、次のようになります。

/**
 * Load rewrite information for request
 * If $path is array - we must load possible records and choose one matching earlier record in array
 *
 * @param   mixed $path
 * @return  Mage_Core_Model_Url_Rewrite
 */
public function loadByRequestPath($path)
{

    $this->setId(null);
    $this->_getResource()->loadByRequestPath($this, $path);
    $this->_afterLoad();
    $this->setOrigData();
    $this->_hasDataChanges = false;
    return $this;
}
4

1 に答える 1

1

わかりました、それは速かったです!loadByRequestPathファイル内にあるをこれに置き換えることで問題を解決しました/app/code/core/Mage/Core/Model/Url/Rewrite.php

public function loadByRequestPath($path)
     {
         $this->setId(null);

         if (is_array($path)) {
             foreach ($path as $pathInfo) {
                 $this->load($pathInfo, 'request_path');
                    if (!$this->getId() && !isset($_GET['___from_store'])) {
                    $db = Mage::getSingleton('core/resource')->getConnection('default_read');
                    $result = $db->query('select store_id from core_url_rewrite WHERE request_path = "' . $pathInfo . '"');
                    if ($result) {
                        $storeIds = array();
                        if($row = $result->fetch(PDO::FETCH_ASSOC)) {
                            $storeId = $row['store_id'];
                            $storeCode = Mage::app()->getStore($storeId)->getCode();

                            header("HTTP/1.1 301 Moved Permanently");
                            header("Location: http://" . $_SERVER['HTTP_HOST'] . "/" . $pathInfo . "?___store=" . $storeCode);
                            exit();
                        }
                    }
                }
             }
         }
         else {
             $this->load($path, 'request_path');
         }
         return $this;
     }

Magento のアップグレード時に問題が発生したくない場合は、ローカル コピーを作成することを忘れないでください。

于 2013-06-21T14:48:19.667 に答える