2015-07-20 42 views
3

我試圖理解這一行代碼。如何在Magento中使用Mage :: helper?

$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes()); 

1.對於開始被聲明的變量($_attributes)

2. Mage::helper('core')助手是一個加載對象的方法?什麼是core?一份文件?在哪裏可以找到這個文件?

3. decorateArray是從core class

你能告訴我請這個代碼如何工作,給我一個簡單的例子嗎?

我試圖讓我的網頁

$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes()); 
<?php if($_product->isSaleable() && count($_attributes)){ 
    echo "de vanzare"; 
} 
?> 

也許評估條件假消息,並沒有顯示這個簡短的例子。我沒有錯誤,但沒有工作。

我想看看,如果我理解它是如何工作Mage::helper(這就是爲什麼我做了這個例子)

提前感謝!

+0

Mage :: helper('core')是位於[/Core/Helper/Data.php](http://docs.magentocommerce.com/Mage_Core/Mage_Core_Helper_Data.html)中的輔助類Mage_Core_Helper_Data的一個對象。 。請在開始使用Magento之前閱讀文檔。 –

+0

@Cristi核心是模塊名稱,decorateArray是以下類中的一種方法,請參閱app/code/core/Mage/Core/Helper/Data.php文件。 – Muk

回答

1

Mage::helper('core')屬於app/code/core/Mage/Core/Helper。你可以在這個路徑裏找到decorateArray()到data.php。

Mage文件夾包含magento的核心類。

0

Mage :: helper('myHelper')將加載被調用的幫助程序,在這裏加載Mage_Core_Helper_Data幫助程序。

$ _attributes將包含您調用的函數的結果,這裏是位於Mage_Core_Helper_Data中的函數decorateArray。

相關問題