2010-05-26 25 views
2

我問這個問題,因爲我試圖讓我剛剛從域A中複製的圖像在域B(它使用相同的數據庫)中工作。有沒有人知道Magento中產品圖像文件名之前的32個字符串是什麼?

http://DOMAIN_A/magento/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95 /b/0/b0041-1.jpg

我想知道32字符串是什麼,它幫我找到一個很好的解釋,爲什麼在前面不被發現的圖像或Magento的後端的上域B後重新安裝

RE:Magento的版本1.4.0.1

回答

1

下面是一個創建該文件名路徑的代碼,在Mage_Catalog_Model_Product_Image發現:

// build new filename (most important params) 
    $path = array(
     Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath(), 
     'cache', 
     Mage::app()->getStore()->getId(), 
     $path[] = $this->getDestinationSubdir() 
    ); 
    if((!empty($this->_width)) || (!empty($this->_height))) 
     $path[] = "{$this->_width}x{$this->_height}"; 

    // add misk params as a hash 
    $miscParams = array(
      ($this->_keepAspectRatio ? '' : 'non') . 'proportional', 
      ($this->_keepFrame  ? '' : 'no') . 'frame', 
      ($this->_keepTransparency ? '' : 'no') . 'transparency', 
      ($this->_constrainOnly ? 'do' : 'not') . 'constrainonly', 
      $this->_rgbToString($this->_backgroundColor), 
      'angle' . $this->_angle, 
      'quality' . $this->_quality 
    ); 

    // if has watermark add watermark params to hash 
    if ($this->getWatermarkFile()) { 
     $miscParams[] = $this->getWatermarkFile(); 
     $miscParams[] = $this->getWatermarkImageOpacity(); 
     $miscParams[] = $this->getWatermarkPosition(); 
     $miscParams[] = $this->getWatermarkWidth(); 
     $miscParams[] = $this->getWatermarkHeigth(); 
    } 

    $path[] = md5(implode('_', $miscParams)); 

    // append prepared filename 
    $this->_newFile = implode('/', $path) . $file; // the $file contains heading slash 

所以,哈希是從配置信息(寬高比等)以及水印信息生成的。這些信息通常不會改變。但是,我確實看到該路徑部分來自當前商店的store_id,所以您的麻煩可能在那裏。

有沒有理由讓Magento在兩家商店中都使用正常的緩存過程?由於Magento檢查文件系統的緩存圖像,應該不會有衝突。

希望有幫助!

謝謝, 喬


在沉思,你只是想獲得目錄圖像在這兩個領域的工作?目錄圖像的非緩存版本爲%magento%/media/catalog/product。從該位置複製目錄,並且您的目錄圖像應該可以工作。

+0

謝謝喬。 我試圖複製只是目錄/產品/圖像,仍然沒有喜悅,然後我試圖刪除緩存的圖像,再次,沒有喜悅。結果 - 仍然快樂,仍然卡住試圖讓圖像在4天后加載! – 2010-05-27 08:53:03

+0

兩個安裝都有相同的store_id – 2010-05-27 11:59:18

0

移動緩存的圖像不會走得太遠,因爲它們將在下次刷新Magento緩存時被刪除。因此,移動了/ media/catalog/product中的圖像後,請刷新Magento圖像緩存。確保文件權限正確無誤。然後,一頭扎進Mage_Catalog_Model_Product_Image並看看下面的代碼(約行270):(取決於您是否啓用了日誌記錄)

if ($file) { 
     // add these for debugging 
     Mage::log($baseDir.$file); 
     Mage::log(file_exists($baseDir.$file)); 
     Mage::log($this->checkMemory($baseDir.$file)); 

     if ((!file_exists($baseDir . $file)) || !$this->_checkMemory($baseDir . $file)) { 
      $file = null; 
     } 
    } 

添加var_dumpMage::log聲明在那裏,並驗證路徑圖像是正確的,並且您有足夠的內存進行操作。如果沒有圖像路徑存在,這是爲您選擇默認圖像的代碼。如果仍然無法獲得,請發佈這三條日誌語句的輸出結果,我們會繼續嘗試。 :)

+0

我清空了圖像緩存,清除了管理面板中的緩存,仍然無法使用。 然後我添加了你的線條,並嘗試了不同的產品。 我收到一條關於異常處理消息的錯誤屏幕。 這裏是系統的3條線。日誌 2010-05-27T15:36:24 + 00:00 DEBUG(7):/var/www/vhosts/handmadejewelleryuk.co.uk/subdomains/dev/httpdocs/media/catalog/product/n/0/ n0014-2_1.jpg 2010-05-27T15:36:24 + 00:00調試(7): 〜 (這看起來對我來說正確) – 2010-05-27 15:39:12

+0

這只是兩行。你說你從日誌中得到了代字符?確保提到的文件存在並且可讀(賦予它世界可讀的權限)。 至少我們知道它現在正在尋找一個真實的文件。 – 2010-05-27 17:11:18

+0

從那時起,我一直無法讓它尋找一個真正的文件,它不會使它進入if($ file)循環..並且只是加載佔位符...得到了Magento樂觀情緒後的下沉感覺!謝謝約瑟夫:) – 2010-05-27 18:16:24

相關問題