我有一個受保護的數組。將一個項目添加到數組IF條件語句
class Tric_FullCircle_Model_Product_Adapter extends OnePica_FullCircle_Model_Product_Adapter
{
/**
* Global company number
*/
protected $_globalCompanyNumber = null;
/**
* Tax Classes
*/
protected $_taxClasses = null;
/**
* Attributes to update
*
* @var array
*/
protected $_attributesToUpdate = array(
'name',
'description',
'price',
'tax_class_id',
'weight',
'country_of_manufacture',
'specifications',
'tric_cn',
'tric_style',
'tric_color',
'tric_div',
'tric_div_desc',
);
我想,如果一個特定的默認存儲其中1
我一直在我的保護變量數組拋出語法錯誤匹配添加「special_price」。我是否使用array_diff
?或只是追加像這樣$arr[] = 'special_price';
我想是這樣的
if (Mage::app()->getStore()->getStoreId() !== Mage::app()->getWebsites()[1]->getDefaultStore()->getStoreId()) {
$arr[] = 'special_price';
}
這
if (Mage::app()->getStore()->getStoreId() === Mage::app()->getWebsites()[1]->getDefaultStore()->getStoreId()) {
$_attributesToUpdate = array_diff(fieldNames, array('special_price'));
任何幫助,將不勝感激。謝謝。
顯示你正在做什麼引發錯誤。 – Rasclatt
使用var_export並更新您的答案,以便我們可以幫助您 –
在同一個類中,您應該沒有問題,您只需執行'$ this - > _ attributesToUpdate [] ='special_price';' – Rasclatt