Magento seems to include the “Login” link by default. However, Magento does not seem to show a link to Logout after one logs in.
If you have been searching tirelessly for a solution to your Magento logout woes, have no worries your search is at an end! We’ve already searched and found. We’ve included the code you will need to add a Logout link to Magento. This code actually only displays the pertinent link – so if a user is already logged in they will only see a Logout link and if a user is not Logged in then they will see a Login link.
It always take time to get rid of the Magento cache. However cache is needed to execute the request faster. One way of clearing the cache is delete all the directories inside the /var/cache directory. Doing that manually it will take some time if you are connected to the FTP server.
The easiest way of clearing the cache in Magento is here.
Are you looking for the solution i.e. customer can provide their inputs or comments along with the products they are going to order. To make it easier, one way is to allow them enter the comments for each individual item they order.
On the other hand, admin should be able to view the comment on the order page.
Adding a custom comment box for each item in the cart is actually very easy. First lets add the textarea field for each item.
In your theme, for the file: template/checkout/cart.phtml
Add the new heading along with other heading for cart items.
__('Comments') ?>
In the file: template/checkout/cart/item/default.phtml
Add a new column
For Older version of Magento it would be:
Doing upto this. shoul show the text area added
The next step is to save the comment in DB, when customer update the cart.
So add a new field ‘itemcomment’ in the tabel ‘sales_flat_quote_item’. (For older version of Magento the table would be ‘sales_quote_item’)
Now we are going to add the code which will do the DB operation. For this we will need to modify the file:
app/code/core/Mage/Checkout/Model/Cart.php (Note: If you are planning to upgrade your Magento setup, copy this file to local & modify.)
Here we need to add some code to the function updateItems(), such a way that the function should now look like below:
public function updateItems($data)
{
Mage::dispatchEvent('checkout_cart_update_items_before', array('cart'=>$this, 'info'=>$data));
foreach ($data as $itemId => $itemInfo) {
$item = $this->getQuote()->getItemById($itemId);
if (!$item) {
continue;
}
if (!empty($itemInfo['remove']) || (isset($itemInfo['qty']) && $itemInfo['qty']=='0')) {
$this->removeItem($itemId);
continue;
}
$qty = isset($itemInfo['qty']) ? (float) $itemInfo['qty'] : false;
if ($qty > 0) {
$item->setQty($qty);
}
/* Start: Custom code added for comments */
if(!empty($itemInfo['comments'])) {
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
# make the frame_queue active
$query = "UPDATE `sales_flat_quote_item` SET itemcomment = '".$itemInfo['comments']."' where item_id = $itemId";
$write->query($query);
$item->setItemcomment($itemInfo['comments']);
}
/* End: Custom code added for comments */
}
Mage::dispatchEvent('checkout_cart_update_items_after', array('cart'=>$this, 'info'=>$data));
return $this;
}
Showing the comment in Admin -> View Order
Add a new function getItemcomment() to the file below:
app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items.php
If you are on verstion 1.5 or later.. add it to the file below.
app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items.php
public function getItemcomment($item) {
$itemId = $item->getId();
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$query = "SELECT q.* FROM `sales_flat_order_item` o
LEFT JOIN `sales_flat_quote_item` q on o.quote_item_id = q.item_id
WHERE o.item_id = $itemId";
# For older versions of Magento
/* $query = "SELECT q.* FROM `sales_order_entity_int` o
LEFT JOIN `sales_flat_quote_item` q on o.value = q.entity_id
WHERE o.entity_id = $itemId AND o.attribute_id = 343"; */
$res = $write->query($query);
while ($row = $res->fetch() ) {
if(key_exists('itemcomment',$row)) {
echo nl2br($row['itemcomment']);
}
}
}
To add the comments column to the items edit the .phtml file below:
app/design/adminhtml/default/default/template/sales/order/view/items.phtml
Adding header for items to make it look like below:
.
.
helper('sales')->__('Product') ?>
helper('sales')->__('Comments') ?>
helper('sales')->__('Item Status') ?>
.
.
.
Adding Column with comments. app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml
Add a column for item comments juts before status columns to make it look a like below.
.
.
getItemcomment($_item) ?>
getStatus() ?>
.
.
Doing upto this will show the comments column in the item table. It should look like image below.
Here is a quick and useful code on getting actual price and special price of any product in Magento. The actual price is the real price assigned to the product and special price is the price after any discount is applied to the product.
A demo store is where there are products but the order done by customer is not processed. If your website is in development mode then it is better to enable demo store notice.
Enabling demo store notice in Magento is very simple. You just need to select an option in configuration settings in admin panel.
Go to System -> Configuration -> Design -> HTML Head -> Display Demo Store Notice
By default, it is set as ‘No’. To enable demo store notice, select ‘Yes’.
Now, you will see a notice bar at top of your page saying ‘This is a demo store. Any orders placed through this store will not be honored or fulfilled.‘
Magento provides a number of web services to ease the life of programmers and users. You will find web services for adding, deleting, listing, editing of products, customers, shipments etc. But Magento lacks a very important web service- Placing Orders. Magento says that it is due to security reasons so that a hacker does not break into your site and place unwanted orders. But no worries, I have found a way out, a simple one. I have developed the web service for placing an order in Magento.
Open the file: app\code\core\Mage\Sales\etc\api.xml
Here search for methods tag inside sales_order parent tag an add the folloeing lines to it
Here is the step by step procedure to enable contact form from magento back-end
Step 1. System > Configuration > Contacts
Step 2. Click the ‘Contact Us’ section on this page. Set ‘Enable Contact Us’ to ‘Yes’
Step 3. Click the ‘Email Options’ section on the same page, just under it. Set the email
address to which the comments should come, subject and email template.
The line 5 presents the Magento initialization, and from there you can call any Magento core API functions and procedures. In order for session to work properly (as one) in both sites, you need to retrieve it, and that is exactly what is done on the lines 6 (for the core session) and 7 (for the customer session). Later in our example we’re checking whether the customer is logged in or not, but you can do whatever you want!
Oh yes, on more thing – Use SID on Frontend setting in the Magento admin (System -> Configuration -> Web -> Session Validation Settings) MUST be set to YES, otherwise it won’t work.
Magento Provides the manage customers feature to list and edit the customers information.
The Customer edit page in the admin panel gives details about the customers account information,address,orders etc.
In some scenarios we may need to show our custom module contents related to the customer in a additional tab. To achieve this functionality we need to create a custom module and add our tab.
Step 1: We start with our config.xml file. In this file we are specifying an adminhtml xml layout file and a Block class for our custom module.
Step 2: We need to create an adminhtml block class to show our new custom tab. This class
should extend the Mage_Adminhtml_Block_Template class and implement Mage_Adminhtml_Block_Widget_Tab_Interface to
get the tab related methods.
The following method allows you to add confirmation email address field in your customer registration or newsletter page.
Create a javascript file called validation.js under "js/email/validation.js"
Validation.addAllThese([
['validate-cemail', 'Please make sure your emails match.', function(v) {
var conf = $('confirmation') ? $('confirmation') : $$('.validate-cemail')[0];
var pass = false;
var confirm;
if ($('email')) {
pass = $('email');
}
confirm =conf.value;
if(!confirm && $('email2'))
{
confirm = $('email2').value;
}
return (pass.value == confirm);
}],
]);
Magento has some stint functionality which are optionally used just like enable free shipping module method on grant total of the order such like free shipping on orders over $50.
1. Login to Admin page go to System > Configuration
2. Under “Sales” on the left, select “Shipping Methods”
3. Select the Free Shipping Tab to open it
4. Set “Enabled” to “Yes”
5. Set “Minimum Order Amount” to the subtotal that must be reached before the “Free Shipping” option is available
6. Click “Save Config” in the upper right.
That’s it. No “Shopping Cart Price Rules” necessary.
If you need to add a new product attribute in a Magento store you should follow the next steps:
1. Log in to the Magento admin panel
2. Open the “Attributes” page.
3. Click the “Catalog” tab in the Magento admin main menu.
4. Select “Attributes” and click the “Manage Attributes” button. Here you can see all the attributes used in the Magento store. You can click any of them to see their attribute options and change some if needed.
5. Let’s add a new attribute. Click the “Add New Attribute” button. You can see the attribute options page:
- “Attribute Code” field. It is the name of the attribute used by the system. The drop-down menu determines the level at which the values of this attribute are shared.
- “Global” means that the value of this attribute for a given product must be the same throughout your site.
- “Website” option means that the value of this attribute for a given product can vary in different Websites.
- “Store View” means that the value of this attribute for a given product can differ in all Websites and all store views.
Each new product created with this attribute will automatically have this attribute pre-populated with the value you enter here. However, you will always be able to edit the pre-populated value. If you designate the attribute to be a unique value, the value selected or entered for this attribute for each product must be different.
If you require values, you should select a value for this attribute for each product you create. You will not be able to save a product if this attribute is left blank.
Decide which product types will include this attribute. You can specify if this attribute is available in the quick search and in the advanced search. If you opt for “Yes”, a row for this attribute will be created in the “Compare Products” pop-up window. If you select “Filterable” (with results), only the values that correspond to products in that category page will display in the menu.
You can also see the position of the attribute in the layered navigation menu against other filterable attributes.
6. Ok, we’re done with attribute properties and now we can proceed to the “Manage Options” page. Click the “Manage Label/Options” button.
- You can specify the attribute title for each language and for the admin page
- You can add attribute options
7. Specify which attribute value is default
8. Set the attribute options order.
9. When you are done, click the “Save Attribute” button.
For changing the administrator password you should:
1. Log in to your Magento admin panel
2. Select the “System” tab
3. click the “My Account” menu item
4. Here you can see the fields where you can enter your admin password
In case you are not able to log in to your Magento admin panel at all, the admin password can be changed in the database directly.
1. Open your database with the “phpMyAdmin” tool or any other database management tool. And open the “admin_user” table
2. Click the edit icon
3. With that done, type your new password in the value field
4. Note that in the function drop-down menu you should select “MD5″
5. Save the changes
Adding Multiple Products To The Cart Simultaneously
In a previous post I looked at creating a product on the fly and adding it to the cart automatically. However, if you are using Magento without the catalog then when you transfer customers from your catalog to the cart and checkout you may need to create and add multiple products to the cart.
Creating multiple products is fairly straightforward if you use my methodology for creating a single product from the previous post. To add multiple products to the cart, create the products and add the product objects to an array, here I have named it $products.
To then add all of these products to the cart simultaneously use the following code:
<?php
equire_once (‘app/Mage.php’);
Mage::app();
$session = Mage:getModel(‘core/session’, array(‘name’ => ‘frontend’);
// create products here and add the objects to the array $products
$ids = array();
foreach ($products as $product)
{
$ids[] = $product->getID();
}
$cart = Mage::getModel(‘checkout/cart’);
$cart->addProductsByIDs($ids);
$cart->save();
// change to relevant URL for your store!
header(“location: http://localhost/magento/checkout/cart/”);
?>
Sometimes it’s necessary to create products on-the-fly, typically in situations where there are so many product possibilities that even a configurable product isn’t flexible enough! In such situations the need arises to create products dynamically.
Below is the PHP code to produce a single Magento product and add it to the cart.
Most of time I have spend in finding proper sql queries for magento. And I have come to know that, its very good idea to not to use your personal sql query but use the magento syntax for doing such. Let me give you a good example to do this. We all are aware that we can use normal “is equal” query but have you ever tried to use “not null” ????
Magento is vast eCommerce online shopping cart development tool, and magento community and official peoples are keep upgrading with the new version of magento in eCommerce market with new structured development, and everybody wants their should be upgraded with the latest version of magento, and i can say this is not a big job to upgrade if everything is professionally installed.
But you need to aware of few things before upgrading your online store with latest one.
1. Backup your source files.
2. Go to magento backend – Systems >> Tools >> Backup and create backup.
3. You can also create backup using phpmyadmin but it is often getting failed due to time limit in php.ini so just go with System >> tools >> Backup only or else you can dump the magento database using ssh command.
4. Verify the code.
5. You need to confirm if you have done any core hacks in php files of magento MVC structure because on upgradation it will override all the core files of magento and clear your changes and will override with new code.
6. Download all the source code via FTP or control panel.
7. Truncate(remove) cache from /var/cache.
8. Truncate(remove) session from /var/session.
After clearing all above steps just follow below steps to upgrade your magento web store.
1. Just go to you browser and open http://www.yourwebstorename.com/downloader/
2. Access above URL with the user who have all the access over store in nutshell use Administrator.
3. Then just paste the “magento-core/Mage_All_Latest” in the extension install box and just press enter.
4. It will upgrade all the magento core modules automatically.
5. After successfully upgradation just clear your cache and session again.
6. hurrey you are done, :)
Now what if somebody wants to upgrade specific core modules with the latest code.
just use below commands in the extension installation box in http://www.yourmagentostore.com/downloader
Magento is a confusing piece of software sometimes, and it’s always best to make backups of anything before you make changes, so that’s the first step in the process.
Go ahead and back up your files and database(s) before you begin. This step is mandatory just in case something goes awry.
You should be able to upgrade via the Magento Connect Manager. This can be found in the System menu in the Magento admin panel.
First, login to your Magento admin panel, then navigate to
System > Magento Connect > Magento Connect Manager
. You’ll need to re-login using the admin account here.
If this is the first time you’re logging into Magento Connect, you’ll need to prepare the downloader by typing
“magento-core/Mage_All_Latest”
in the Extension Key field, and then click on the Install button. Once the initial setup procedure has completed, click on Refresh. This will update a list of currently installed Magento packages.
Next, click the ‘Check for Upgrades’ button. Once complete, any modules available to be upgraded will be highlighted in yellow. Select the “Upgrade to ..” option in the dropdown menu next to each package you are upgrading, OR, to upgrade the entire Magento store, only select Mage_All_Latest,.
I strongly recommend that ‘Clear all sessions after successful install or upgrade’ is enabled to help with the process.
Click on Commit Changes to begin the upgrade. This may take some time, so keep an eye on it. The console with green text at the bottom will display the output of pear. It will let you know when the upgrade is complete. You should simply need to refresh the page to confirm the changes have been made.
To ensure you are running the upgraded version, go back to your Magento admin panel and scroll to the bottom of any page. The version number should be displayed in the middle.
Magento has a nice inbuilt feature of Newsletter Subscription , but sometimes you may need to call it to a separate or CMS page. So, in order to do that, you can just use this code,
In EAV database model, data are stored in different smaller tables rather than storing in a single table.
Like,
product name is stored in catalog_product_entity_varchar table
product id is stored in catalog_product_entity_int table
product price is stored in catalog_product_entity_decimal table
EAV database model is used by Magento for easy upgrade and development as this model gives more flexibility to play with data and attributes.
When flat catalog is enabled in Magento then all the above product attributes (id, name, price) are kept in one table named like catalog_product_flat. Then Magento fetches product data from the flat table rather than joining all the other smaller tables.
There are two types of Flat Catalog:
1) Flat Catalog Product
2) Flat Catalog Category
- Flat Categories are recommended for any Magento installation for improved performance.
- Flat Products is designed and recommended for catalogs that have over 1000 SKU’s.
Enable Flat Catalog Category:
- Go to Admin Panel->System->Cache Management->Rebuild Flat Catalog Category
- Go to Admin Panel->System->Configuration->Catalog->Frontend->Use Flat Catalog Category = Yes
Enable Flat Catalog Product:
- Go to Admin Panel->System->Cache Management->Rebuild Flat Catalog Product
- Go to Admin Panel->System->Configuration->Catalog->Frontend->Use Flat Catalog Product = Yes
Sometime you need to play with the price format. magento default add 2 precision format for the price. now if you want to remove precision or want to keep 3 decimal point for price then you need to do following
1) Open /lib/zend/Currency.php file
2) Find 'precision' => 2 near line no. 78
here is the place, you need to change precision decimal
Change 'precision' => 0 if you want to keep 0 decimal
Here is the script to read and write to the database in magento
READ QUERIES
// Prepare the SQL
$sql = "SELECT * FROM mytable";
// Execute the SQL and return the results in to $getData
$getData = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($sql);
// Parse the results
for($i=0; $i < count($getData); $i++){
/* your code */
}
WRITE/UPDATE Queries
// $write is an instance of Zend_Db_Adapter_Abstract
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
// Prepare the SQL statement
$sql = "insert into tablename values (?, ?, ?)";
// Execute the SQL
$write->query($sql);
while ($row = $write->fetch() ) {
/* your code */
}
Customising your magento store can be a good way to set your store apart from the competition so adding features that require javascript files is a common task when building a project. Learn how to include a javscript file into your magento page templates with this quick how to.The default layout template load is made primarily through the page.xml file located at the following url for custom themed installs /app/design/frontend/your-instance-name/your-theme-name/layout/page.xml , or for the default theme at /app/design/frontend/default/default/layout/page.xml.
Find the following block encapsulator and simply add the following command inside the block
Then upload you updated page.xml file.
With that done, you need to now upload your javascript file to /skin/frontend/your-instance-name/your-theme-name/js/yourscriptname.js, or for the default theme /skin/frontend/default/default/js/yourscriptname.js
From magento cart you can delete product by clicking on delete button from cart page , but if you wish to delete any cart item in checkout page or by coding then you have write
By writing the above code your all cart item will be delete.If you wish to delete a particular product from the cart session then instead of writing $item->getId() pass your Id of the product.
Here I have Created a new Module to Add new tab in admin panel of magento.
My Namesapce Name is Anjan and My Module name is Systab
As you know to make a module first we need to make a .XML file with Namespace_Module name under app/etc/modules/ folder. So My File name will be Anjan_Systab.xml
Now I will write the following code inside this xml
truelocal
As My CodePool is local which is written in Anjan_Systab.xml I will create a Folder with name Anjan inside app/code/local/, then again will create another folder with name Systab inside Anjan Folder.Now I will create an etc folder inside the Systab Folder. Inside the etc folder I will create config.xml and will write the following code
n the last post I have showned , how to add new Tab in magento admin panel. Now in this post I will add new Tab under System->Configuration.To add so, You need to create a new module. Click here to create an admin Module then make some changes which is written here.
create a system.xml file inside etc folder of your module, Then write the following code to add a tab
Now important things which needs to do. Go to your System->Cache Management then clear your all cache. Now go to System->Permissions->Roles. Clcik on Administrators, from Role Resources Tab select Resource Access All from the drop down and save. Now go to System ->Configuration .You can see a new tab has added in the left side.
This is what I used many times while developed magento sites. I have made Feature products , Special Producst, Hot products etc by the custom attribute. To do so I am going to make some Special Product which will show on frontend, for this I will create a custom attribute Special Product whose code name will be special. First Log in to admin panel then Catalog->Attributes -> Manage Attributes . Now click on Add new Attribute, I n the Attribute Code field write special and from Catalog Input Type for Store Owner select Yes/No from the drop down, Choose NO from the Default Value .Now click on Manage Label / Options then in the Admin field write Special Product then click on Save Attribute button to save the attribute.
Now go to Catalog-> Attributes -> Manage Attribute Sets . Click on your Attribute set (e.g : - I choose Default attribute set) then add the Special attribute from Unassigned Attributes to Groups by drag and drop. Now go to any products which have same attribute set in which the Special Attribute is assign, There you can see that Special Product Option has came with yes/no drop down. Now make some product Yes as Special product.
Now go to frontend and write the below code where you want to fetch the Special Product.
$storeId = Mage::app()->getStore()->getId();
$resource = Mage::getSingleton('core/resource');
$read = $resource->getConnection('catalog_read');
$categoryProductTable = $resource->getTableName('catalog/category_product');
$productEntityIntTable = (string)Mage::getConfig()->getTablePrefix() . 'catalog_product_entity_int';
$eavAttributeTable = $resource->getTableName('eav/attribute');
// Query database for special product
$select = $read->select()
->distinct()
->from(array('cp'=>$categoryProductTable),'cp.product_id')
->join(array('pei'=>$productEntityIntTable), 'pei.entity_id=cp.product_id', array())
->joinNatural(array('ea'=>$eavAttributeTable))
->where('pei.value=1')
->where('ea.attribute_code="special"');// Write your attribute code instead of Special
$rows = $read->fetchAll($select);
// Save all product Id which have the Special Product Yes
foreach($rows as $row)
{
$product[] =$row['product_id'];
}
Inside the $product variable you have all product Id which are Special Product . Now write the Below code to get Details of the Each product
To make magento more SEO friendly, It needs to redirect to a custom url, By default magento have this feature but if you have created any module whose url like modulename/id/3, then you needs to redirect it to a SEO friendly url. To redirect the url to a "301 Permanent redirect" you just login to your admin panel, then go to -> Catalog -> URL Rewrite Management, from the drop down select Custom ,follow the below screenshot to make it more easy.
1) In the Id path give your current url (e.g: review/product/list/id/14/category/3)
2) In Request Path write same as Id path (e.g: review/product/list/id/14/category/3)
3) In Target Path give oyu custom Url with domain name (e.g:- http://www.mysite.com/mobile.html)
To add New Status in magento admin panel, you need to write your own custom module , then in your config.xml file write the below code to add new Status
It will work upto 1.4.2 , But in Magento 1.5.0 or above there is Special Option to do this. To make own Custom status above magento 1.5 version go to System->Order Statuses. Then Click on Create New Status. After creating new status click on Assign Status to State to assign that status
If you forgot to upload any product image then Magento always show a default image,If you think to change default image then login to admin panel then goto System -> Configuration then click on Catalog tab. From Product Image Placeholders change your Base Image , Small Image and Thumbnail . Now click on Save Config button to make changes.
Configurable product is the product which is created by some Associated product, If you have an configurable product and you want to get list of all associated product and it's attribute then just write the below
You must have your configurable product Id, My configurable product Id is 15
$id=15; //Use your Configurable product Id
$_product = new Mage_Catalog_Model_Product();
$childIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($id);
foreach($childIds[0] as $key=>$val)
{
$associatedProduct = Mage::getModel('catalog/product') ->load($val);
echo $associatedProduct ->getName();
//Let you have a color attribute in each associated product then you can fetch by
$colorids[] = $associatedProduct ->getColor();
$colorname[] = $associatedProduct ->getAttributeText('color');
}
If you are making your custom module in magento and if you unable to use default magento file upload then you can use magento custom file uploading code to upload file.
// If you want to upload files under media folder
$absolute_path = Mage::getBaseDir('media') . DS ;
$relative_path = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
// File Upload
$files = $_FILES['file_upload']['name'];
if(isset($files) && $files != '')
{
try
{
if(file_exists($absolute_path.DS.$files))
{
$var = rand(0,99);
$files = $var.'_'.$files;
}
// Starting upload
$uploader = new Varien_File_Uploader('file_upload');
// Any extention would work
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
$uploader->setAllowRenameFiles(false);
//false -> get the file directly in the specified folder
//true -> get the file in the product like folders /media/catalog/product/file.gif
$uploader->setFilesDispersion(false);
//We set media as the upload dir
$uploader->save($absolute_path, $files);
}
catch(Exception $e)
{
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
// Your uploaded file Url will be
echo $file_url = $relative_path.$files;
}
In product page you can get gallery image of the current product, But if you think to fetch all gallery image of a product in other page like cms page, then you have to write the code with little bit modification. The code should looks like below
load($id);
// Use your Product Id instead of $id
$countt = count($Products_one->getMediaGalleryImages());
if($countt>0){
foreach ($Products_one->getMediaGalleryImages() as $_image)
{
// For the Original Image
echo "url)." alt='' />";
//For gallery Image
$resizeimage = $obj->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->backgroundColor(242,242,243)->resize(400,300);
echo "";
}
}
When we load a category it shows his subcategory according to the product id. If you wish to show category according to the order which you have in you admin panel then you have to fetch your category with little bit different style.See the below code in which I have fetched all subcategory with proper order
Any body can send mail using php mail() function.But in magento all the functionality has wriiten you need to just send argument inside those functions. See the following script to send mail using magento function
setToName('Your Name');
$mail->setToEmail('Youe Email');
$mail->setBody('Mail Text / Mail Content');
$mail->setSubject('Mail Subject');
$mail->setFromEmail('Sender Mail Id');
$mail->setFromName("Msg to Show on Subject");
$mail->setType('html');// YOu can use Html or text as Mail format
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
$this->_redirect('');
}
catch (Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send.');
$this->_redirect('');
}
?>
By default magento shows zero in the place of quantity text field in product details page, if you wish to change then just login to your admin panel go to System->Configuration->Catalog->inventory.
There, add your minimal quantity from Minimum Qty Allowed in Shopping Cart
In the World some of the country has no zip code like Ireland, But magento has default zip code validation to make that optional for specific country magento has added a new feature in admin panel. To make Zip code optional please follow the following steps.
Login to your your magento admin panel then go to System -> Configuration->General. From Country option tab you can see there is an option " Postal code is optional for the following countries " Select the country which you want to Optional/Not validate . then click on save config to save your settings. To be more clear on this please see the below screenshot.
First of all to make Minimum Order Amounts of Free Shipping to [STORE VIEW] instead of [WEBSITE] then Go to app->code->core->Mage->Shipping->etc->System.xml
then change the value of to 1 under carriers -> groups -> freeshipping ->free_shipping_subtotal.
Now to fetch the value of the Minimum Order Amount according to store view write the below code
Or you can change it from admin -> System-> Configuration. From the left tab select Contacts then On the right side you will see Email Options Tab. From that tab you can see there is a field for send Emails To.Change th evalue to your require email address
On Magento, on the Shopping Cart page, just before the checkout, by default, you have an area where customers can enter a coupon code. Obviously, if you’re running some kind of discount scheme, this is a vital area – however, if you’re not, it can actually take up a lot of much needed room during the checkout! For this reason, you might want to simply get rid!
Well, here’s how… just navigation through your FTP folders to: app/design/frontend/default/default/layout and in there you should see a file called checkout.xml.
Simply open it up and comment or delete the following line:
Last week I was speaking to a Magento user, and he said he wanted to not only have the Product Title listed in the Magento Checkout, but also the short Product Description there. Most people would perhaps not have the neccessity to do so, however, for those that do want it done, there is a solution about.
If you go into FTP and navigate to /app/design/frontend/default/default/template/checkout/cart/item/default.phtml, you simply need to add the following around Line 27…
So, your web-site sells all sorts of home furniture, and you have a Christmas section. It is two weeks until Christmas Day, and you realise you’ve got quite a lot of seasonal stock that you need to shift – as you don’t want to be left with a warehouse full of Christmas Trees, Christmas Wreaths and Garlands do you?
Well, offering discounts on those products is probably an idea, and why not do it via a coupon code – that way, you can send a lovely email out to all your customers informing them that if they type in XMAS15 on your checkout, they’ll get a whopping 15% off their order.
With some E-Commerce platforms you might have a few problems with trying to offer money off for specific products or categories – however, with Magento, thankfully this is childs play – and it only takes a couple of seconds to set up.
In your Magento Admin system, simply click on Promotions, and then click on Shopping Cart Price Rules – and then click Add New Rule.
On the left you’ll see three tabs, in the uppermost one you’ll have to name your Price Rule, choose which website it will be activated on and what customers will see it, and also name the actual coupon code itself.
It is then the followed tab (entitled “Conditions”) which is the important one, as this area specifies which products/categories will be available for the promotion. So, click the little green plus, and then select “Product Attribute Combination” – this will create a rule which says “[Do this] If an item is found in the cart with all of these conditions true”…
On this occasion we want to select products from certain categories, so click the green plus again and select “Categories”. Then you can select which of the categories that you’ll like to be enabled – simply click the drop down box and save it.
At this point your rule will say “Category IS 167, 168, 171, 174, etc”. You’ll need to click on the “IS” and change it to “IS ONE OF”.
Subsequently, as long as you save it all and apply the rules, you have now successfully made sure that certain products within your store are now available at 15% off. Furthermore, you can do these reductions based on a plethora of rules including SKU, Colour, Price, nearly any attribute you can think of. You could have a “Blue Monday” if you wanted, offering money off on every product that is blue – that is how random and deep you can go with this amazing piece of E-Commerce software!
I find it a tad annoying how on Magento, you’ve got this empty quantity box next to the Buy Now/Add to Basket button. Although clicking the button alone will add an item to the cart, some users may experience doubt in this motion, and enter the quantity required AS WELL as press the button.
But why even have any doubt? Why not just make the default quantity set to 1 – well this something that a lot of people have required, and fortunately, I have got the answer!
In app\design\frontend\default\default\template\catalog\product\view\type\Simple.phtml
Here is a quick guide on how to change admin url path in Magento. This need to be done for security reason to be safe from hacking/cracking issue. Basically, this is done not to let any general user to access the admin page.
Generally, we do have ‘admin‘ as the administrator path for Magento. So, the admin URL will be http://www.example.com/admin/
This article will show you, how you can change the admin url. Let’s say from ‘admin‘ to ‘backend‘. So, the new admin URL will be http://www.example.com/backend/
- Save the file
- Refresh the Cache from Magento Admin (System -> Cache Management)
Now, you should be able to access admin panel from http://www.example.com/backend/ instead of http://www.example.com/admin/
Important Note
If you just need to change the admin base URL then the proper way I find is by doing the change in local.xml like explained above, instead of editing configuration setting from admin like said below.
I tried to change the Admin Base URL from Magento admin panel. But, I ran into problem and could not access the admin after that. Here is what I did:-
- System -> Configuration -> ADVANCED -> Admin -> Admin Base URL
- Changed Use Custom Admin URL = Yes
- Changed Custom Admin URL (Once I tried with ‘backend/’ and then with ‘http://www.example.com/backend/’)
To solve the problem, I had to make some change in database. If you had similar problem then here is a workaround:-
- Open your database
- Browse table ‘core_config_data‘
- Search in path field for ‘admin/url/use_custom‘ and set its value to ’0′
- Search in path field for ‘admin/url/custom‘ and set its value to empty
- Search in path field for ‘web/secure/base_url‘
- You will find two row result. One with scope = default and another with scope = stores.
- Edit the value of row with scope = stores with the value of the row with scope = default
- Similarly, repeating the process for ‘web/unsecure/base_url‘:-
- Search in path field for ‘web/unsecure/base_url‘
- You will find two row result. One with scope = default and another with scope = stores.
- Edit the value of row with scope = stores with the value of the row with scope = default
- Now, you will be able to login to Magento admin with your old admin base URL.
A new secret key is created every time you login to Magento Admin. So, there will be a unique key (32 chars long) for each session of your Magento admin login. This key is appended to the admin URL as http://your-admin-url/key/743c37b1…adf6588/
This is basically added for security reason. In their release note, Magento say that they added secret key to URL for CSRF (Cross-site request forgery) Attack Prevention.
Cross-site request forgery, also known as a one-click attack or session riding and abbreviated as CSRF or XSRF, is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts. Unlike cross-site scripting (XSS), which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user’s browser.
You can learn more about CSRF here:- http://en.wikipedia.org/wiki/Cross-site_request_forgery
Sometime you may want to access admin URL without the secret key. For this, you can disable the secret key from admin URL.
Here is how you do it:-
- Login to admin
- Go to System -> Configuration -> ADVANCED -> Admin -> Security -> Add Secret Key to URLs
- Select No
- Save Config
You are done. You will not see the secret key in admin URL nowonwards.
In this article I will show you quick tip that will help you solve common problems in Magento: “Can’t send header. Header already sent” in Magento.
I got this error when I have managed to bring back the client store. Basically, this error happens when there is an extra space or character outside the the php tag . Thanks to the help of excellent Magento users, I have been able to solve it. I think it will be useful if I explained steps by steps what I personally have done so that you can reference it later. When this error happens, you should try the following things.
Open the file that has the problem. In my case, this file is index.php in the site root of Magento.
Open the file with some text editors that supports the encoding. I prefer Notepad++ because its great support in multi languages as well as encoding.
If you open it by Notepad++, click on the menu Encoding, click on UTF-8 without BOM. Save it and then re-upload it to the server.
We just save the error file in the UTF-8 encoding to make sure that everything extra space, line is wiped out. Encoding without BOM ensures you will not have any extra, unwanted characters in the file that prevent it from being executed properly.
Hi, this is Mohan Natarajan working as a Senior Software Engineer at DCKAP Technologies.I have completed BE Computer Science and Engineering in Ranipet Engineering College. I did my schooling in Govt Boys Hr Sec School Timiri.(Vellore Dist)