1

I have a protected array.

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', ); 

I want to add 'special_price' if it matches a particular default store which 1.

I keep throwing syntax errors in my protected variable array. Do i use an array_diff? or just append it like this $arr[] = 'special_price';

I tried something like this

if (Mage::app()->getStore()->getStoreId() !== Mage::app()->getWebsites()[1]->getDefaultStore()->getStoreId()) { $arr[] = 'special_price'; } 

and this

if (Mage::app()->getStore()->getStoreId() === Mage::app()->getWebsites()[1]->getDefaultStore()->getStoreId()) { $_attributesToUpdate = array_diff(fieldNames, array('special_price')); } 
6
  • Show what you are doing that throws the error. Commented Aug 4, 2016 at 23:13
  • use var_export and update your answer so we can help you Commented Aug 4, 2016 at 23:16
  • 1
    Inside the same class, you should have no problems, you would just do $this->_attributesToUpdate[] = 'special_price'; Commented Aug 4, 2016 at 23:21
  • What about the IF statement... i know my IF statements are correct ... the problem is what you said above putting it together with my IF statements. not sure how to do that. Commented Aug 4, 2016 at 23:26
  • oh.. i see what you're saying... drop that inside the { } Commented Aug 4, 2016 at 23:28

1 Answer 1

1

Access your protected array with $this->

Change

arr[] = 'special_price'; 

To

$this->arr[] = 'special_price'; 

OR

Change

_attributesToUpdate = array_diff(fieldNames, array('special_price')); 

To

$this->_attributesToUpdate = array_diff(fieldNames, array('special_price')); 
Sign up to request clarification or add additional context in comments.

5 Comments

only if statement is true... i know both of my IF statements would probably work... i'm just not sure how to insert it into that array... does that make more sense?
I should just be able to use the bottom line of your answer inside my { } correct?
Where do i put the IF statement so it doesn't throw a syntax error?
Tell me the array variable you're updating? or put your adding statement here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.