Skip to main content

Posts

magento create admin user programatically

Create test file in root directory and place code in to that file and run yoursiteurl.com/test.php  <?php       # Create New admin User programmatically.      require_once('./app/Mage.php');     umask(0);    Mage::app();    try {                    $user = Mage::getModel('admin/user')->setData(array(                     'username'  => 'pawan',                     'firstname' => 'pawan',                     'lastname'    => 'kumar',                     'email'     => 'n.pavan37@gmail.com',                     'password'  =>'pawan123',     ...

Topmenu not functioning after upgrade magento 1.8 fatal error addCacheTag()

ERROR :: Fatal error: Call to a member function addCacheTag() on a non-object in public_html/app/code/core/Mage/Catalog/Model/Observer.php on line 215 you can find the lines 241 ::   $menuBlock->addModelTags($categoryModel); 215 ::   $block->addCacheTag(Mage_Catalog_Model_Category::CACHE_TAG); here is not error fixing place in block class is " Mage_Page_Block_Html_Topmenu " you can find getHtml function in that you can see Mage::dispatchEvent('page_block_html_topmenu_gethtml_before', array(             'menu' => $this->_menu         )); replace above code to below code  Mage::dispatchEvent('page_block_html_topmenu_gethtml_before', array(         'menu' => $this->_menu,         'block' => $this         //add this line ));

Magento create custome options for all products using programatically

For this we can update custome options programaticallyfor alla products at a time :) <?php require_once 'app/Mage.php'; umask(0); Mage::app('admin'); $option = array(     'title' => 'custom option title',     'type' => 'drop_down', // could be drop_down ,checkbox , multiple     'is_require' => 1,     'sort_order' => 0,     'values' => getOptions() ); $collection = Mage::getModel('catalog/product'); $product_id = $collection->getIdBySku('Ac-43SS'); $product = $collection->load($product_id); $product->setProductOptions(array($option)); $product->setCanSaveCustomOptions(true); $product->save(); echo $sku; function getOptions() {     return array(         array(             'title' => 'Ship It',             'price' => 0,             'price_type' => 'fixed...