开发者

Does anyone know what is the 32 character string before the product image filename in Magento?

开发者 https://www.devze.com 2022-12-31 21:13 出处:网络
I ask this question, since I am trying to get the images I have just copied from Domain A to work in Domain B, (which is using the same database).

I ask this question, since I am trying to get the images I have just copied from Domain A to work in Domain B, (which is using the same database).

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

I think knowing what the 32 c开发者_开发知识库haracter string is, which help me find a good explanation why the images are not being found in the front or backend of Magento after reinstall on DOMAIN B.

RE: Magento version 1.4.0.1


Here's the code that creates that filename path, found in 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

So, the hash is generated from the configuration info (aspect ratio, etc), as well as the watermark info. This information will not usually change. However, I do see that the path is partially generated from the store_id of the current store, so your trouble may be there.

Is there a reason you can't let Magento use its normal caching procedures for both stores? Since Magento checks the filesystem for the cached image, there shouldn't be a conflict.

Hope that helps!

Thanks, Joe


Upon contemplation, are you just trying to get the catalog images to work in both domains? The non-cached version of the catalog images are at %magento%/media/catalog/product. Copy the directories from that location and your catalog images should work.


Moving over the cached images isn't going to go far, since they will be deleted next time you flush the Magento cache. So, having moved the images that are in /media/catalog/product, flush the Magento image cache. Make sure that the file permissions are correct for reading. Then, head into Mage_Catalog_Model_Product_Image and take a look at the following code (approx line 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;
        }
    }

Add a var_dump or Mage::log statement in there (depending on whether you have logging enabled), and verify that the path to the images is correct, and that you have enough memory for the operation. This is the code that will choose the default image for you if no image path exists. If you still can't get it, post the output of those three logging statements and we'll keep trying. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消