2010-05-26 39 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

相关问题