<?php error_reporting(E_ALL | E_STRICT); $mageFilename = 'app/Mage.php'; require_once $mageFilename; umask(0); Mage::app('admin'); try { $user = Mage::getModel('admin/user') ->setData(array( 'username' => 'admin1', 'firstname' => 'Admin', 'lastname' => 'Admin', 'email' => 'waytest@test.com', 'password' =>'admin123', 'is_active' => 1 ))->save(); } catch (Exception $e) { echo $e->getMessage(); exit; } //Assign Role Id try { $user->setRoleIds(array(1)) //Administrator role id is 1 ,Here you can assign other roles ids ->setRoleUserId($user->getUserId()) ->saveRelations(); } catch (Exception $e) { echo $e->getMessage(); exit; } echo "User created successfully"; ?>
How to pragmatically create admin user in Magento
To create Admin User copy this code in your file and put this file on Magento root directory.
How to get Magento layout outside of Magento
I integreated wordpress in my magento store and I will try to get magento data in wordpress file.
I want to same header in my both site magento and wordpress.
I tryed to hard and finally got the solution to get any magento layout in wordpress.
Below are the script to
get magento layout outside of magento.
<?php require_once '/home/.../public_html/.../app/Mage.php'; umask(0); /* not Mage::run(); */ Mage::app('default'); // get layout object $layout = Mage::getSingleton('core/layout'); //get block object $block = $layout->createBlock('page/template_links'); /* choose whatever category ID you want */ //$block->setCategoryId(3); $block->setTemplate('page/template/links.phtml'); echo $block->renderView(); ?>
Listing sub-categories on a category page with category images.
This tutorial is going to show you one of the ways to list sub-categories on category pages of your Magento store.
In order to display thumbnails of subcategories and their names on your category pages:
1:-In your Magento admin go to CMS -> Static Blocks
2:-Click “Add New Block” at the top right.
3:-Create a new static block as follows:
Block Title: Sub Category Listing
Identifier: subcategory_listing
Status: Enabled
Content:
1:-In your Magento admin go to CMS -> Static Blocks
2:-Click “Add New Block” at the top right.
3:-Create a new static block as follows:
Block Title: Sub Category Listing
Identifier: subcategory_listing
Status: Enabled
Content:
{{block type="catalog/navigation" template="catalog/navigation/subcategory_listing.phtml"}}
How to Create a block in Magento
Many time we need to create a new block in Magento sites.There are two types of Block in Magento:-
1. Structural Blocks
2.Content Blocks For more detail see here.
Step 1 :- Now we are going to create a new Structural Blocks for this you have to create a new file local.xml in your them's layout folder and put this code:-
<?xml version="1.0"?>
How to modify/change shpping price in Magento
If you want modify or change Shipping price in Magento then we can do it using Observer So let's see how to do it:- We are going to create a Custom Module for it.
Step 1:- So let's create a config file Arunendra_Extrashipcost.xml in app/etc/modules put following code in this file:-
<?xml version="1.0"?>Step 2:- create following folder and file under app/code/localtrue local
1:-Arunendra/Extrashipcost/etc/config.xml
2:-Arunendra/Extrashipcost/etc/Model/Observer.php
Step 3:-Put following code in config.xml file:-
<?xml version="1.0"?>Step 4:-Put following code in Observer.php file:-0.1.0 Arunendra_Extrashipcost_Model singleton extrashipcost/observer salesQuoteCollectTotalsBefore
<?php class Arunendra_Extrashipcost_Model_Observer { public function salesQuoteCollectTotalsBefore(Varien_Event_Observer $observer) { $quote = $observer->getQuote(); $store = Mage::app()->getStore($quote->getStoreId()); $carriers = Mage::getStoreConfig('carriers', $store); $newFee = floatval($carriers['flatrate']['price'] * 0.15); foreach ($carriers as $carrierCode => $carrierConfig) { if($carrierCode == 'flatrate'){ Mage::log('Handling Fee(Before):' . $store->getConfig("carriers/{$carrierCode}/handling_fee"), null, 'shipping-price.log'); $store->setConfig("carriers/{$carrierCode}/handling_type", 'F'); #F - Fixed, P - Percentage $store->setConfig("carriers/{$carrierCode}/handling_fee", $newFee); ###If you want to set the price instead of handling fee you can simply use as: #$store->setConfig("carriers/{$carrierCode}/price", $newPrice); Mage::log('Handling Fee(After):' . $store->getConfig("carriers/{$carrierCode}/handling_fee"), null, 'shipping-price.log'); } } } } ?>
how to add a custom column in Magento sales/order grid
Step 1 :- Copy app\code\core\Mage\Adminhtml\Block\Sales\Order\grid.php
to
app\code\local\Mage\Adminhtml\Block\Sales\Order\grid.php now Find _prepareColumns() function to Add column use this code:-
$this->addColumn('color ', array( 'header' => Mage::helper('sales')->__('color #'), 'index' => 'color', 'sortable' => false, 'filter' => false, 'renderer' => 'Mage_Adminhtml_Block_Sales_Order_Renderer_Productatt', ));Step 2:- Create a new file at :-
app\code\local\Mage\Adminhtml\Block\Sales\Order\Renderer\Productatt.php add this code :-
<?php class Mage_Adminhtml_Block_Sales_Order_Renderer_Productatt extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract { public function render(Varien_Object $row) { $order = Mage::getModel('sales/order')->load($row->getData('entity_id')); $attribute =""; foreach($order->getAllVisibleItems() as $_item){ $product = Mage::getModel('catalog/product')->load($_item->getProductId()); if($product->getAttributeText('color')){ $attribute .= $product->getAttributeText('color'); } } unset($order); return $attribute; } } ?>
How to send custom attribute in magento Order email.
Recently i was working on a project and my client want to send a custom shipping note in order email.
So lets's see how to achieve this:-
Create a file On this location app/design/frontend/your_package/your_theme/template/email/shipnote.phtml in this file i am getting shipnote info i am installed following extension for it :-
https://github.com/drewhunter/ShipNote
Now in shipnote.phtml i have added following code.
So lets's see how to achieve this:-
Create a file On this location app/design/frontend/your_package/your_theme/template/email/shipnote.phtml in this file i am getting shipnote info i am installed following extension for it :-
https://github.com/drewhunter/ShipNote
Now in shipnote.phtml i have added following code.
<?php $order = $this->getOrder(); $shipNoteId = $order->getShipNoteId(); $ShipnoteModel = Mage::getModel('shipnote/note')->load($shipNoteId); echo 'Pickup Location :- '.$ShipnoteModel->getNote(); ?>Now open your transactional email template you can find it system->>Transactional Emails or app/locale/en_US/template/email/sales/order_new.html and add following code in it:-
{{block type='core/template' area='frontend' template='email/shipnote.phtml' order=$order}}
Fix CSS hover on iPhone/iPad/iPod
Copy this code and paste it any where in your file.
Make sure jQuery included in your page.
Make sure jQuery included in your page.
Subscribe to:
Posts (Atom)