2016-05-13 166 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); ?>第一個參數是寬度,第二個是高度。 –