Magento eCommerce Tips Archives

If, you get a message like this:  “Please enter a valid credit card verification number.” every time you enable “CVV check” in your payment gateway, and you are sure that your payment module settings are correct and your card details are valid then, its most likely that the message is not coming from your payment module.

Instead it could be that the control is not reaching the payment module at all and the message is coming from this Magento file:
app/code/core/Mage/Payment/Model/Method/Cc.php line #150, validate credit card verification number section.

Why is this happening? Does this error occur for ‘Saved CC’ payment method too (it is the default card payment method got with Magento)?

Well, one reason that I found is – custom checkout module. Are you using any custom checkout module? If yes, then disable it and try the normal Magento one page checkout. The chances are all will work fine. I have noticed that some custom checkout modules fail to send the CVV number back to the code – hence, Magento will catch it and throw back the error – the payment module is nowhere in the picture yet.

So, before you panic that your card details are invalid or your Payment Gateway or payment module is not working, confirm that it is not your custom checkout module that is the culprit.

Incoming search terms:

  • deactivate card verification number magento
  • mage code cvv magento
  • magento cc cvv
  • magento credit card verification
  • magento enable card verification payment
  • magento please enter a valid credit card verification number
  • magento saved cc credit card verification
  • save cvv magento

Intro to Themes

A theme is a combination of files which are responsible for the visual output.

What files form the theme ?

Magento themes are split into two directories.  The files are separated into “browser accessible” (such as image and Javascripts) and those that can be hidden from it for security reasons.

  • Directory 1: app/design/frontend/default/default/ — This directory contains the layout, translation (locale) and template materials.
  • Directory 2: skin/frontend/default/default/ — This directory contains the images, CSS and block-specific Javascripts.

So a theme consists of the following files :

Layout (located in app/design/frontend/your_interface/your_theme/layout/)
These are basic XML files that define block structure for different pages.

Templates (located in app/design/frontend/your_interface/your_theme/template/)
These are PHTML files that contain (X)HTML markups and any necessary PHP tags to create logic for visual presentation.

Locale (located in app/design/frontend/your_interface/your_theme/locale/)
Theses are simple text documents organized on a per language basis that contain translations for store copy.

Skins (located in skin/frontend/your_interface/your_theme/)
These are block-specific Javascript and CSS and image files that compliment your (X)HTML.

Hierarchy of themes:

Magento has a very powerful theme concept. For instance, you can use a default theme which comes with Magento and a new one of your own side by side. That new individual theme only contains files which differ from the default theme. Thus it forms a hierarchy of themes.

For example If you simply want to move the mini cart from the left sidebar to the right sidebar you just copy the required file from “default” to your new theme directory and adjust some code. Magento first loads all files from your new theme and then falls back to the next theme lower in hierarchy (in this case “default”) and requires all missing files from that theme.

Doing so, Magento conserves the ability to be upgraded. With every upgrade,  files in your default theme are getting overwritten. The original files are protected this way.

What are Blocks ?

In Magento we work with structural blocks and content blocks. Structural blocks represent the basic structure of a page. Usually we have structural blocks like header, left sidebar, middle content, right sidebar and footer. We can assign content blocks like category list, navigation, search bar, callout etc. to a certain structural block.

themes_blocks

Content blocks are assigned to structural blocks with the help of layout. Layout is build with XML files and can be found under app/design/frontend/default/default/layout. This way you can reuse earlier created templates, such as the mini cart module on the sidebar, on different pages by simply calling them within a layout xml file.

themes_layout

In this case we are adding the content block ‘cart_sidebar’ (shopping cart) to the structural block ‘left’.

Template Path Hints:

You can see info about the template that a block uses by turning on Template Path Hints. Here are the steps to turn on template path hints. Make sure you disable your cache by going to System->Cache Management.

Open admin page and go to System->Configuration. Then Select Developer on the left sidebar. Also select Main Website from the Current Config Scope Drop Down.  Next Open the debug drop down and set template hints to yes.


templaetspathhints

The result will be as follows. Each content block will be outlined and labeled with the location of template file which is used to design that block.

magentotemplatetip

Incoming search terms:

  • content and footer structure in seo

How to change default pages like home page in Magento

Steps to change default pages like home page in Magento

Login as admin and select System->Configuration, then select Web from GENERAL. Click on Default Pages, and assign pages for CMS Home Page, Default no-route url, CMS No Route Page. Then click on Save Config button.

Change best selling products

Default Magento installtion homepage has a section ’Best Selling Products’. You want to put your products to appear instead…follow these steps:

  1. Login as Admin -> CMS -> Manage Pages
  2. Edit the ’Homepage’ page
  3. In the ’Content’ textarea you will find the ’Best Selling Products’ section like this
    Technorati Tags: ,,

    The bold section is

Incoming search terms:

  • how to change best selling products in magento

First,Login as admin and in the admin Home Page select  System ->Configuration.

Under the Configuration tab on the left Side Select Shipping Settings.Here you can Find two options Origin and Options.From that you Can Change Settings Such as Country,Regional,etc.

Now Select Shipping Methods next to Shipping Settings.Under that you can find Flat rate,Table rate,Free Shipping,UPS etc.Let us see One by One.

1) Flat rate:

Fill the necessary field  in the Flat rate as specified above.

2)Table rates:

Here in the table rate select Enabled as Yes for displaying table rate in front end.Fill the remaining field as Specified above and Select Yes for the option Show method if not applicable which is not shown in the above Figure.Then in Export option.Click on Export CSV.This will export a empty tablerate.csv file.open a file with Spread Sheet and Edit Your Data.Here is the Sample Spread Sheet.


Here I enter the data for the different field such as Country,Region,Zip/Postal,Weight,Shipping Price.In Region and Zip/Postal Filed,I enter as * which denotes all regions and all Postal Codes.Here Weight and Shipping Price denotes that if the weight of the Product is between $0 and $49.99 then the shipping Charge would be $15.If it is between $50 and $99.99 then the shipping charge would be $10 and so on.

3)Free Shipping


Fill the required field in Free Shipping Tab as Specified above.Here You Can set Minimum Order amount.So that the Product Which exceeds this Minimum order amount will have Free Shipping.

Then For the remaining Option You can choose  Courier Service as your wish and Fill the Specified Fields.After that click on Save Configuration to save your configurations.

Then Come to Front End and Reload the Page.Add any Product into Your Cart and Proceed Check Out.In the CheckOut Page you have enter your details and in the Shipping Information You can see the Flat Rate,Table rate, Shipping Value For the Product.Here You can see the Shipping rate as $0 because we have added the Product in the cart which exceeds $100.

That’s it!!!


Magento write custom log messages

A quick debugging tip for developers. You can write custom messages into Magento’s system log  or exception log – helpful for knowing the current variable or object state etc.

How to enable log

Admin > System > Configuration > Developer > Log Settings
Set “Enabled” to “Yes”

Code to write into the log

Mage::log("Hello");
Mage::log("Hello Again");

Where to check?

Your custom message should most probably be in the var/log/system.log file but, in case you do not find it there, you can also check the var/log/exception.log file.

New log messages are found at the bottom of the log file.
Ensure that your log folder and files have enough permissions to write.

The log message will look like this:

2010-04-14T13:40:24+00:00 DEBUG (7): Hello
2010-04-14T13:41:31+00:00 DEBUG (7): Hello Again

In this article I want to give some custom options to my product named “Linux

Select Product from Catalog -> Manage Products

On the Left side you can take “Custom Options” inside “Product Information

Click on the button “Add New Option

You can give as follows:

Title : Company

Input Type : Drop Down

Is Required : Yes

Sort Order : 1

After that you will get an option below like “Add New Row“. Click that Button

Input the fields as below:

Title: Red Hat
Price: 2000
Price Type: Fixed
SKU: rh123
SortOrder: 1

Add a New Row and give data as below:

Title: Suse
Price: 900
Price Type: Fixed
SKU: suse123
SortOrder: 2

Here one more option is being given. So click on the “Add New Option” again.

You can give as follows:

Title : Edition

Input Type : Radio Button

Is Required : Yes

Sort Order : 1

Click “Add New Row” and input the fields as below:

Title: Home
Price: 500
Price Type: Fixed
SKU: home123
SortOrder: 1

Give one more “Add New Row” and input as below:

Title: Office
Price: 750
Price Type: Fixed
SKU: office123
SortOrder: 2

It looks like the picture shown below:

Custom Options

You can add any number of rows as you want.

The Front End will show options like this:

Custom Options

Similarly you can also use Text Area, Text Field, Radio Button, Multiple Select and Check boxes. Try with new values and have a look.

How to enable the default Magento contact form?

  1. System > Configuration > Contacts
  2. Click the ‘Contact Us’ section on this page. Set ‘Enable Contact Us’ to ‘Yes’
  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.
  4. Click ‘Save Config’

How to add a custom field to the default Magento contact form?

  1. Open [magento_root]/app/design/frontend/default/default/template/contacts/form.phtml in your favorite editor
  2. Copy & paste an existing form field code on this script and rename the field to create new field. For example:
    This is the default  code in the file:

    This is how the modified code will look like:

  3. Now go to, System > Transaction Emails.
  4. Click ‘Add New Template’
  5. In the ‘Load default template’ section, select ‘Contact Form’ template and click ‘Load Template’
  6. The template content will look like this:

  7. Add your new field in this content like this:

  8. Enter a new ‘Template Name’ and click ‘Save template’
  9. Now go to, System > Configuration > Contacts
  10. Click the ‘Email Options’ section on this page and select the new template that you just created.
  11. Click ‘Save Config’

How to add a link to the contact form on the top menu bar?

  1. Open [magento_root]/app/design/frontend/default/default/template/catalog/navigation/top.phtml in your favorite editor
  2. After this line:

    Add a line like this:
  3. Click the Magento cache; System > Cache Management

Reference links:

  1. http://www.magentocommerce.com/wiki/how_to/add_fields_to_contact_form
  2. http://www.richardcastera.com/2009/08/17/magento-add-additional-fields-to-the-contact-form/
  3. http://www.magentocommerce.com/boards/viewthread/21707/
  4. http://inchoo.net/ecommerce/magento/contact-form-in-magento/

Incoming search terms:

  • online contact form creator in magento
  • add contact us link in magento
  • magento enable contact us page
  • magento contact us comment fields empty
  • magento contact us add a new required field
  • magento contact form top menu
  • magento contact form in top menu
  • magento 1 7 add extra fields in contact form & email
  • how to put captcha in contact us page in magento
  • how to give contact us page link in magento topmenu phtml
Try the following steps,
1. Try accessing your admin using your ip (if it is localhost, try 127.0.0.1).
2. If you cant get around with the above step then as a last step try the following,
Navigate within your Magento database to the MySQL table core_config_data and look for a row with the field path set to the valueweb/cookie/cookie_domain. There might be multiple entries, but the one with the scope_id set to 0 should be matching the domainname you’re using to access Magento.
3. Another problem could be that the so-called Secure URLs and/or Unsecure URLs do not match the current hostname.
In the same MySQL table core_config_data you might find various entries with path starting withweb/secure/base or web/unsecure/base. These also need to point to the right hostname. Note that the number of occurances could range from 0 (nothing configured) to 10 (everything configured).

Magento, Fatal Error while installing

I got the following fatal error while trying to intall Magento 1.3.2.4 in XAMPP 1.7.3
Fatal error: Method Varien_Object::__tostring() cannot take arguments in C:\xampp\htdocs\magento\lib\Varien\Object.php on line 488

Follow the steps given below to fix this issue:-
1)File: /lib/Varien/Object.php (Line 484)
Change from
public function ___toString(array $arrAttributes = array(), $valueSeparator=’,')
To this
public function __invoke(array $arrAttributes = array(), $valueSeparator=’,')

2)File /app/code/core/Mage/Core/Controller/Request/Http.php (Line 274)
Change from
$host = split(‘:’, $_SERVER['HTTP_HOST']);
To this
$host = explode(‘:’, $_SERVER['HTTP_HOST']);

Incoming search terms:

  • Unknown error (8192): Function split() is deprecated in app\code\core\Mage\Core\Controller\Request\Http php on line 274
Page 2 of 512345