0

Is it better to use this :-

    $subcat= $_brands = $category = Mage::getModel('catalog/category'); 

or this :-

        $category = Mage::getModel('catalog/category'); 
        $subcat = Mage::getModel('catalog/category');
        $_brands = Mage::getModel('catalog/category');
1

depends on how u use it...

PHP creates references to objects.

$cat1 = $cat2 = Mage::getModel('catalog/category');
$cat3 = Mage::getModel('catalog/category')

$cat1->setId(1);
$cat2->setId(2); // $cat1 also gets overwritten
$cat3->setId(3);

echo $cat1->getId(); // 2
echo $cat2->getId(); // 2
echo $cat3->getId(); // 3

So you could get unexpected results if u use it wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.