2016-05-13 126 views
2

在产品视图页面页面,图像从该路径服务:link1更改产品图片路径的路径的Magento网站

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> 
+0

[产品图像是从不同的路径服务于商品详细页和网站地图]的可能的复制(http://stackoverflow.com/ question/37185755/product-images-are-serving-from-different-paths-on-product-detail-page-and-in-si) – codedge

回答

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() 
    ); 

这种 “$ PATH” 阵列将建立您的目录映像路径。将其改为任何你喜欢的。你的情况:

// 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())); ?> 
+0

感谢您的支持,对于延迟抱歉,我们使用的是扩展名:https: //www.magentocommerce.com/magento-connect/dexxtz-product-zoom.html,现在我使用后端设置图像大小,所以我得到我需要的路径,但图像显示在网站[这里]非常大的大小, (http://test.collagekingapp.com/baby-ball-large .html) – fresher

+0

你可以像这样添加一个“resize”参数:'<?php echo $ dexxtz-> getImageFeatured($ this-> helper('catalog/image') - > init($ this-> getProduct(), 'thumbnail',$ _image-> getFile())) - > resize(300,300); ?>第一个参数是宽度,第二个是高度。 –