Skip to content Skip to sidebar Skip to footer

Which File Should I Use When Assigning Products To A Category In Magento Programatically?

I am new to Magento. I have created a category in the back end of Magento. There are quite few threads about how to assign a product to a category, however I don't understand which

Solution 1:

Code examples like that is for developers (which I'm kind of guessing you're primarily not) to put into their own modules, maybe as an observer running on the product save event.

For you I would instead recommend testing out snippets like that in small freestanding files in your magento-folder. At least until you know how to make a proper module this is the easiest way to run some custom code, that perhaps only needs to run once.

Create file triggerCustomAction.php in your Magento root directory, making it accessible from www.yourdomain.com/triggerCustomAction.php to run it once.

Use this as a starting point, with code you need to run at the bottom of the file:

<?phprequire'app/Mage.php';
if (!Mage::isInstalled()) {
    echo"Application is not installed yet, please complete install wizard first.";
    exit;
}

Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);

// this can be changed from to any store ID number like this:// Mage::app()->setCurrentStore(xx);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

//enter your code to run below here:

Post a Comment for "Which File Should I Use When Assigning Products To A Category In Magento Programatically?"