initialize magento from php shell interface
Magento can be run on php command line. All it needs is to include the Mage.php file. Assume you have Magento installed on your machine, then you can enter the php interactive shell interface, include the Mage.php, call Mage::app();
to initialize Magento, and you will be able to use all sorts of Magento functions that starts with Mage such as these
Mage::getModel('customer/customer')->load(2346132); Mage::getModel('catalog/product')->load(23451); Mage::getModel('sales/order')->load(1235623); Mage::getSingleton('core/resource')->getConnection('core_write'); Mage::app()->getStore(1)->getConfig('general/locale/timezone');
Here is a series of commands on the command line does what’s described above.
$> php -a Interactive shell php > include "/Users/pye/dev/bookspan-mage/app/Mage.php"; php > Mage::app(); php > $customer = Mage::getModel('customer/customer')->load(55250403); php > echo $customer->getEmail(); test@example.com php >
These can also be written in a php file and the result will be the same by running the php file. php test.php
<?php include "/Users/pye/dev/bookspan-mage/app/Mage.php"; Mage::app(); $customer = Mage::getModel('customer/customer')->load(55250403); echo $customer->getEmail();
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts