1

Hello I'd like to Assign Sort Order of Product in Category with Catalog Flat Enabled, is there a workaround to let this custom method I've created work without calling the admin store? Right now trows exception. I've already solved calling

Mage::app('admin'); 
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

but I would like to avoid that because is messing up the router after I save redirecting me to the admin area.

I've also tried to add at the beginning:

Mage::register("isSecureArea",1);

and at the end of the method:

 Mage::unregister("isSecureArea");

but without success. This is the method:

 public function assignCategories($category_ids, $productId){
    $position = 120;
    try {
        $api = Mage::getSingleton('catalog/category_api');
        foreach ($category_ids as $category_id) {
            $api->assignProduct($category_id, $productId, $position);
        }
    } catch (Exception $ex) {
        Mage::log($ex, null,"Error.log");

    }
}

many thanks.

Your Answer

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

Browse other questions tagged or ask your own question.