<?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"; ?>
Showing posts with label Magento. Show all posts
Showing posts with label Magento. Show all posts
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.
Labels:
Magento
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(); ?>
Labels:
Magento
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"}}
Labels:
Magento
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"?>
Labels:
Magento
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'); } } } } ?>
Labels:
Magento
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; } } ?>
Labels:
Magento
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}}
Labels:
Magento
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.
how to change shipping method from radio to dropdown in Magento
Today my client want to change shipping method from radio to dropdown on onepage checkout after a lot of googling i not found any proper solution for this.
Then i tried it my self and it's worked for me so i am share my coding here :-
To make shipping method from radio to dropdown copy this file at this location:-
app/design/frontend/your-theme-package/your-theme/template/checkout/onepage/shipping_method/available.phtml
Then i tried it my self and it's worked for me so i am share my coding here :-
To make shipping method from radio to dropdown copy this file at this location:-
app/design/frontend/your-theme-package/your-theme/template/checkout/onepage/shipping_method/available.phtml
You can download file here.
Labels:
Magento
How to Show product options in product list page in Magento
In this article, we will recommend some effective methods to show options for the configurable and product options in product list. Check them out!
Showing options for Configurable products :-
Labels:
Magento
How to Set Up Table Rate Shipping in Magento
In this tutorial, we’re going to look at how to set up table rate
shipping in Magento, giving you the ability to charge different shipping
rates to individual customers based on their location–from the regional
all the way down to the postcode level.
Essentially what this means is that you can set cheaper shipping to certain destinations if the cost of the item is high, or if the weight and number of items is low.
While logged in as admin, navigate to System > Configuration and then, in the left menu under Sales, select Shipping Methods.
Three ways to price shipping
One thing to note, before we start, is that there are three main ways of setting up table rates–price vs. destination, weight vs. destination and number of items vs. destination.Essentially what this means is that you can set cheaper shipping to certain destinations if the cost of the item is high, or if the weight and number of items is low.
Configuring table rate shipping
You set table rate shipping inside the System menu accessed via Magento’s backend.While logged in as admin, navigate to System > Configuration and then, in the left menu under Sales, select Shipping Methods.
Labels:
Magento
Change shipping address dropdown to div in Magento
If you want to change shipping address dropdown to div structure.
After a long research i found that this select box is comming form core php file and it's hard to make any change in core file. So we have to change in shipping.phtml file as following.
Step 1 : Open shipping.phtml you can find it :-
/app/design/frontend/package/yourtheme/template/checkout/onepage/shipping.phtml
Please find this code around line no 30.
<?php echo $this->getAddressesHtmlSelect('shipping') ?>
Labels:
Magento
Set Payment Method "PayPal" on Particular State Only in Magento
If you want to disable a specfic payment method for specfic State then follow these steps.
1.Make a new file in app/etc/module/Arunendra_Disablepayment.xml
copy and Paste below code in that file
<?xml version="1.0"?>2.Now make module folder inside app/code/local/Arunendra/Disablepayment 3.Make new folder and file inside app/code/local/Arunendra/Disablepayment/etc/config.xml and copy and paste below code in that file.true local
Labels:
Magento
How to disable specfic payment method for specfic products in Magento
How to disable specfic payment method for specfic products
If you want to disable a specfic payment method for specfic products then follow these steps.
1.Make a new file in app/etc/module/Arunendra_Disablepayment.xml
copy and Paste below code in that file
<?xml version="1.0"?>2.Now make module folder inside app/code/local/Arunendra/Disablepayment 3.Make new folder and file inside app/code/local/Arunendra/Disablepayment/etc/config.xml and copy and paste below code in that file.true local
Labels:
Magento
Disable admin notification popup in Magento
Every time you log in to the Magento Admin Panel, you see an admin notification popop message telling you there's a new Magento version. As a developer, it's best to stay informed about new releases by reading blogs, tweets and lots of other news channels - besides this, upgrades should never be taken lightly. It's possible to remove this notification popup message.
To remove this notification popup message.
To remove this notification popup message.
- Login to your Magento Admin Panel
- Go to System >> Configuration >> Advanced
- Disable the Mage_AdminNotification module
Labels:
Magento
How to create custom page layout in magento
To create a new custom column layout, you need to place a new file in the Magento theme. With the Magento default theme, you could use the folder app/design/frontend/default/default/template/page, but of course - when building your own site - it is recommended to have your own theme-directory.
In the tutorial, the file 1column.phtml is copied to the file 1columnfp.phtml (where "fp" stands for the front page). To make this new page reckognizable you wll need to add a new XML-definition. In the tutorial the following code is added to the file app/code/core/Mage/Page/etc/config.xml. copy this module in local exp app/code/local/Mage/Page/etc/config.xml
In the tutorial, the file 1column.phtml is copied to the file 1columnfp.phtml (where "fp" stands for the front page). To make this new page reckognizable you wll need to add a new XML-definition. In the tutorial the following code is added to the file app/code/core/Mage/Page/etc/config.xml. copy this module in local exp app/code/local/Mage/Page/etc/config.xml
However, with a Magento upgrade this change could be gone. The same XML could also be added to your app/etc/local.xml file instead:page/1columnfp.phtml page_one_column_fp
Labels:
Magento
Customizing Magento email templates
Emails (or often referred to as transactional emails) are - just like the entire Magento theme - based on files in the filesystem: If you open up the folder app/locale/en_US/template/email you will numerous files. Don't edit them directly, because any Magento upgrade will override your changes. Instead, the purpose of these files is to override them.
You can override these email templates either using the Magento Admin Panel, or by copying them to your Magento theme. The first approach allows for easy editing using the Magento Admin Panel, but this interface lacks nice editing features like syntax highlighting or code completion. Ofcourse, you can copy the textarea contents ofcourse to your local editor modify things there and copy the code back into the textarea once you're done.
Labels:
Magento
Get Upsell products list using Product Id in Magento
Using Product ID you can get list of Upsell product. Copy following code and place it in you custom file.
<?php // Get product object. $object = Mage::getModel('catalog/product'); /* Get product detail using product id : $_product->getId() */ $product = $object->load($_product->getId()); // Fetch list of upsell product using query. $upsell_product = $product->getUpSellProductCollection()->addAttributeToSort('position', Varien_Db_Select::SQL_ASC)->addStoreFilter(); //check if record is empty or not $count = count($upsell_product); if(empty($count)) : //if empty echo "Record not found"; else: //if result is not empty then get upsell product detail using foreach loop foreach($upsell_product as $_upsell): //get detail of single upsell prdocut using upsell product id $upsp = $object->load($_upsell->getId()); echo "Product Name : ". $upsp->getName(); echo "Poduct url : ". $upsp->getProductUrl(); echo "Product regular price : ". $upsp->getPrice(); endforeach; endif; ?>
Labels:
Magento
Display all categories and sub categories on left sidebar in Magento
You can display list of all categories and subcategories in left sidebar including product view page using the following code in Magento. You can display subcategories upto second level using this code. You can create a new file for this code and you can add it in your theme’s catalog XML file like this:
Labels:
Magento
How to make accordion tabs in magento For layered navigation
In this blog I’m going to explain you how to create accordion tabs in magento for layered navigation as displayed below for attributes.
Just navigate to your layered navigation file as shown:
Then open that that file & paste the following jquery script at the end of the page:
app/design/frontend/default/{your folder}/template/catalog/layer/view.phtml
Then open that that file & paste the following jquery script at the end of the page:
#narrow-by-list is the id used in that file(
- ) . If you used different id’s, replace this with your id and save the file. Refresh the cache and reload the browser to see the results. Use no-conflict method in magento. It is a good practice to avoid javascript conflicts in the page.
Labels:
Magento
Subscribe to:
Posts (Atom)