2013-04-05 67 views

回答

2

Im不太確定您是否會從catalog/product_image模型中獲得更多有用的信息。從你的問題,它聽起來像你想要獲取圖像標籤。如果您有權訪問產品對象,則可以使用:

$_product->getMediaGalleryImages()->getItemByColumnValue('label', 'LABEL_NAME')->getUrl(); 

這會返回圖像的標籤。

如果您需要更多幫助,請分享您有權訪問的對象以及您試圖實現的目標。

在該類0​​
+0

甜。這就是我要找的。但是,由於我只有圖像文件名並想從varien對象中檢索該標籤或位置值,因此我將使用的代碼爲:$ this-> getProduct() - > getMediaGalleryImages() - > getItemByColumnValue('file', $這 - > getImageFile()); – 2013-04-06 08:38:43

0

有一個屬性和一組和文件中的一個get函數

物業:protected $_baseFile;

功能

/** 
    * Set filenames for base file and new file 
    * 
    * @param string $file 
    * @return Mage_Catalog_Model_Product_Image 
    */ 
    public function setBaseFile($file) 

public function getBaseFile() 
    { 
     return $this->_baseFile; 
    } 

這意味着:你不會使用這個對象獲得位置。 只需檢查getBaseFile這將返回一個字符串。

我總是建議,對於任何給定的對象,如果從varien_object擴展使用$object->debug();,因爲這提供了很多關於它存儲的信息。

相關問題