更改magento站点中产品图像路径的路径

时间:2016-05-13 10:07:34

标签: magento

在产品视图页面中,图片通过以下路径投放:link1

media/catalog/product/cache/1/image/350x350/9df78eab33525d08d6e5fb8d27136e95/c/h/image-name.jpg

但我想从这条道路上发球:link2

`media/cache/images/1/thumbnail/602f0fa2c1f0d1ba5e241f914e856ff9/catalog/product/c/image-name.jpg` : 

media.phtml

<?php
    $_product = $this->getProduct();
    $_helper = $this->helper('catalog/output');
    $dexxtz = Mage::helper('productzoom');

    $dexxtz->getCss();
    $dexxtz->getJs();
?>

<ul id="etalage">
    <li>                
        <img class="etalage_thumb_image" src="<?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($_product, 'image')); ?>" />
        <img class="etalage_source_image" title="<?php echo $_product->getImageLabel(); ?>" src="<?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($_product, 'image'), true); ?>" />
    </li>
    <?php 
        foreach ($this->getGalleryImages() as $_image) {
            if(Mage::registry('current_product')->getImage() != $_image->getFile()) { ?>                
            <li>
                <img class="etalage_thumb_image" src="<?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())); ?>" />
                <img class="etalage_source_image" title="<?php echo $_image->getLabel(); ?>" src="<?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()), true); ?>" />
            </li> 
        <?php 
            }    
        }
    ?>   
</ul>

1 个答案:

答案 0 :(得分:1)

首先需要将app / code / core / Mage / Catalog / Model / Product / Image.php复制到 app / code / local / Mage / Catalog / Model / Product / Image.php

然后看看刚刚复制的文件,l.313-319:

    // build new filename (most important params)
    $path = array(
        Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath(),
        'cache',
        Mage::app()->getStore()->getId(),
        $path[] = $this->getDestinationSubdir()
    );

这&#34; $ path&#34;数组将构建您的目录图像路径。把它改成你喜欢的任何东西。在你的情况下:

    // build new filename (most important params)
    $path = array(
        Mage::getBaseDir('media'),
        'cache/images',
        Mage::app()->getStore()->getId(),
        $path[] = $this->getDestinationSubdir()
    );

别忘了修改清除缓存路径,l.686:

public function clearCache()
{
    $directory = Mage::getBaseDir('media') . DS.'catalog'.DS.'product'.DS.'cache'.DS;

...到......

public function clearCache()
{
    $directory = Mage::getBaseDir('media') . DS.'cache'.DS.'images'.DS;

接下来,转到 media.phtml 文件。变化:

<?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($_product, 'image')); ?>
...
<?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())); ?>

...到......

<?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($_product, 'thumbnail')); ?>
...
<?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())); ?>