Magento – Adding Magento’s required structure to a php file

PHP

This is a weird request but I've done it before and it worked wonders.

I have a need to make a custom PHP file in my sites root folder. I need to give this file access to all of the magento functions inside.

$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’);

I did this once before successfully when I wrote a script to parse a massive database of trading cards into useful data then has the php script automatically add the cards to the database.

My problem is I did this on a old version of XMAPP that I sadly lost the backup files of when my pc died.

What files do I need to include in a blank php file to have access to the required magento core functions?

Best Answer

Try this

umask(0);
require 'app/Mage.php';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

Now Magento is all fired upp and ready to go

Related Topic