I am using the theme "Love Fashion" for magento, however this is just for info if anyone has come across the same problem with this theme before.
I get the following error Notice: Undefined variable: deal
. The error occurs on two lines, 50 and 61 - however the error shows up twice on line 50 eg.:
Notice: Undefined variable: deal on line 50
Notice: Undefined variable: deal on line 50
Notice: Undefined variable: deal on line 61
This happens for the following code (starting on line 49, ending on line 67):
public function addFilter($filterName,$filtervalue,$condition='='){
if ($deal instanceof Sm_Deal_Model_Deal){
$deal = $deal->getId();
}
if (!$this->_joinedFields){
$this->joinFields();
}
$this->getSelect()->where('deal.'.$filterName.' '.$condition.' ?', $filtervalue);
return $this;
}
public function OrderbyAdd($orderName,$ordervalue){
if ($deal instanceof Sm_Deal_Model_Deal){
$deal = $deal->getId();
}
$this->getSelect()->order('deal.'.$orderName.' '.$ordervalue);
return $this;
}
So my question is, how do i fix the undefined variable in this case?
For example, i use the following code earlier in the same document, but this doesn't give any errors: (starting at line 26, ending at line 47)
public function addDealFilter($deal){
if ($deal instanceof Sm_Deal_Model_Deal){
$deal = $deal->getId();
}
if (!$this->_joinedFields){
$this->joinFields();
}
$this->getSelect()->where('related.deal_id = ?', $deal);
return $this;
}
public function joinFieldsdeal(){
$this->getSelect()->join(
array('deal' => $this->getTable('deal/deal')),
'deal.entity_id = related.deal_id',
array('deal.end_date','deal.start_date','deal.name')
);
$this->_joinedFields = true;
return $this;
}
The question is not a duplicate of "Reference: What is variable scope, which variables are accessible from where and what are “undefined variable” errors?" as this simply explains the basic of functions - which is not the case here.