Posts Tagged ‘Magento’
26
Mar

You see an XML error either on your screen or in your system.log but, you do not know which XML file has caused it? These tips should help you get started:

  • Edit this file on line 432
    [magento root]/app/code/core/Mage/Core/Model/Layout/Update.php
    add this code:

    if (!$fileXml instanceof SimpleXMLElement) {
        // add this log statement - ensure to enable error logging on your shop Mage::log(print_r($filename, true));
        continue;
    }
  • Edit this file on line 515
    [magento root]/lib/Varien/Simplexml/Config.php

    if ($xml instanceof Varien_Simplexml_Element) {
        $this->_xml = $xml;
        return true;
    } else { // add this else statement to the if - ensure to enable error logging on your shop Mage::log(print_r($string, true)); }
  • Clear the Magento cache and reload the page you are working on
  • Now check your /var/lib/system.log file – you should see the XML filename or the XML string that is causing the error.

Additional Help:
As you must have guessed from the file names of the above files:

  • If the error is from this file:
    [magento root]/lib/Varien/Simplexml/Config.php on line 510
    then it, means there is an error in one of your module config files. Check one of these config.xml files:

    • [magento root]/app/etc/modules/config.xml
    • [module path]/etc/config.xml
  • If the error is from this file:
    [magento root]/app/code/core/Mage/Core/Model/Layout/Update.php on line 431
    then, there is an error in your theme layout XML file.

Hope, this helps you debug faster.

, , , ,

04
Jan

As of 1.4.2 it is deprecated to define order statues and states via config.xml. Then, how will you get more order statuses in the admin order details page?

Consider for example you have an order in ‘Pending Payment’ state and you want to change it to ‘Processing’. If, you go to the order details page in the admin you will find only one option in the order status drop down (which is ‘Pending Payment’ itself!)
What if you want to show ‘Processing’ too in the drop down?
You will need to make changes in the Magento sales_order_status_state table like this:

INSERT INTO `sales_order_status_state` (`status`, `state`, `is_default`) VALUES ('processing', 'pending_payment', '0');

[EDIT] Just for your info:
Before 1.4.2 you would need to override the Mage/Sales/etc/config.xml file and modify the <global><sales><order><states> section to look like this:

<global>
.....
.....
	<sales>
.....
.....
		<order>
.....
.....
			<states>
.....
.....
				<pending_payment translate="label">
					<label>Pending Payment</label>
					<statuses>
						<pending_payment default="1"/>
						<processing default="0"/>
					</statuses>
				</pending_payment>
.....
.....
			</states>
.....
.....
		</order>
.....
.....
	</sales>
.....
.....
</global>

, , ,

23
Dec

You have created a static block and now you want to add it to your CMS page.
You can do it in 2 ways. Assume you have created a block called sch_myblock:

1. CMS Page “Content” tab:
// In the CMS page “content” you can include a custom static block like this

{{block type="cms/block" block_id="sch_myblock" template="cms/content.phtml"}}

2. CMS Page “Design” tab:
// In the “Page layout” section you can add a custom block like this

// In the "Page layout" section you can add a custom block like this
<reference name="left">
	<block type="cms/block" name="sch_myblock" before="-">
		<action method="setBlockId"><block_id>sch_myblock</block_id></action>
	</block>
</reference>

, , ,

23
Dec

By default Magento Admin Url is:
http://[your magento shop]/admin

But, what if you do not want to use admin in the URL? For example, you want your admin URL to look like this:
http://[your magento shop]/shopadmin

If, you check your files via FTP you will not see a folder called admin. So, how do you do it?
Open app/etc/local.xml – you will find a section like this:

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[mybiz]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>

The name that you enter in the “frontend” tag is the name that will be used to view the admin.
In this example, the Magento admin URL will be
http://[the magento shop]/mybiz

, ,

29
Nov

If you need to change the Magento {{base_url}} manually (hopefully, you have a very good reason to do this) – all you need to do is edit 2 rows in the core_config_data table:

#1 path: web/unsecure/base_url and
#2 path: web/secure/base_url

That’s it! Don’t forget to clear the cache (deleting var/cache should help)

, ,

03
Oct

Assuming you know how to create a custom module, consider a case where you need to create a URL for your module. Follow these steps:

In your module’s config.xml file:

<modules>
.....
</modules>
<global>
....
</global>
<frontend>
	<routers>
		<schurl> --> name that will used in the URL
			<use>standard</use>  ---> standard means its a frontend url; admin will mean it is a backend url
			<args>
				<module>Mage_Schogini</module>  ---> which is the module to be used
				<frontName>schurl</frontName>   ---> name that will used in the URL
			</args>
		</schurl>
	</routers>
</frontend>
<default>
.....
</default>

Create a controller file TestController.php in your module’s controller folder like this (as you may have guessed, my modules name is Schogini):

class Mage_Schogini_TestController extends Mage_Core_Controller_Front_Action
{
	public function showmsgAction()
	{
		echo 'Here';
	}
}

This is what happens when you browse this URL
http://mymagentostore.com/schurl/test/showmsg/

  • schurl tells that the controller to check is Mage_Schogini (the name that is specified in the config file in the section: args > module)
  • test tells that controllers/TestController.php file must be checked
  • showmsg tells that showmsgAction() method must be called.

Hence, it will look for the method showmsg() inside the Mage_Schogini_TestController class

, , , , , , , , , , , , , ,

07
Jul

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.

, , , , , , , , , , , , , , , ,

27
Feb

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

    <div class="box best-selling">
      <h3>Best Selling Products</h3>
      <table border="0" cellspacing="0">
        <tbody>
          <tr class="odd">
            <td><a href="{{store url=""}}furniture/living-room/gayatri-test1.html"><img class="product-img" src="{{skin url=’images/media/vishi.jpg’}}" border="0" width="95" /></a>
              <div class="product-description">
                <><a href="{{store url=""}}furniture/living-room/gayatri-test1.html">Gayatri Test Product</a></>
                <> See all <a href="{{store url=""}}furniture/living-room/">Living Room</a> </>
              </div></td>
            <td><a href="{{store url=""}}nine-west-women--lucero-pump.html"><img class="product-img" src="{{skin url=’images/media/best_selling_img02.jpg’}}" border="0" width="95" /></a>
              <div class="product-description">
                <><a href="{{store url=""}}nine-west-women--lucero-pump.html">Nine West Women’s Lucero Pump</a></>
                <> See all <a href="{{store url=""}}apparel/shoes">Shoes</a> </>
              </div></td>
          </tr>
          <tr class="even">
            <td><a href="{{store url=""}}olympus-stylus-750-7-1mp-digital-camera.html"><img class="product-img" src="{{skin url=’images/media/best_selling_img03.jpg’}}" border="0" width="95" /></a>
              <div class="product-description">
                <> <a href="{{store url=""}}olympus-stylus-750-7-1mp-digital-camera.html">Olympus Stylus 750 7.1MP Digital Camera</a> </>
                <> See all <a href="{{store url=""}}electronics/cameras/digital-cameras">Digital Cameras</a> </>
              </div></td>
            <td><a href="{{store url=""}}acer-ferrari-3200-notebook-computer-pc.html"><img class="product-img" src="{{skin url=’images/media/best_selling_img04.jpg’}}" border="0" width="95" /></a>
              <div class="product-description">
                <> <a href="{{store url=""}}acer-ferrari-3200-notebook-computer-pc.html">Acer Ferrari 3200 Notebook Computer PC</a> </>
                <> See all <a href="{{store url=""}}electronics/computers/laptops">Laptops</a> </>
              </div></td>
          </tr>
          <tr class="odd">
            <td><a href="{{store url=""}}asics-men--gel-kayano-xii.html"><img class="product-img" src="{{skin url=’images/media/best_selling_img05.jpg’}}" border="0" width="95" /></a>
              <div class="product-description">
                <><a href="{{store url=""}}asics-men--gel-kayano-xii.html">ASICS® Men’s GEL-Kayano® XII</a></>
                <>See all <a href="{{store url=""}}apparel/shoes">Shoes</a></>
              </div></td>
            <td><a href="{{store url=""}}coalesce-functioning-on-impatience-t-shirt.html"><img class="product-img" src="{{skin url=’images/media/best_selling_img06.jpg’}}" border="0" width="95" /></a>
              <div class="product-description">
                <> <a href="{{store url=""}}coalesce-functioning-on-impatience-t-shirt.html">Coalesce: Functioning On Impatience T-Shirt</a> </>
                <> See all <a href="{{store url=""}}apparel/shirts">Shirts</a> </>
              </div></td>
          </tr>
        </tbody>
      </table>
    </div>

, , , , , , , , , , , , , , , , , , , , , ,

24
May

Got this nice extension which puts a ‘Newsletter Sign-up’ check-box on the Magento checkout page.

http://www.magentocommerce.com/magento-connect/QuickModules/extension/1361/checkout-newsletter/

Due to permission restrictions I was not able to connect to the Magento Connect Manager link on my live cart. So I went ahead and installed it on my localhost Magento. Here are the steps:

1. Login into Admin > Magento Connect > Magento Connect Manager
2. Re-entered the admin username/password
3. Enter the extension key I got from the URL above
4. Click “Install”
Configure the module
This is a simple (and extremely useful) module with not much configuration needed.
To enable and configure the module I went to Admin > System > Configuration > Customer > Newsletter
Here I saw a new section ‘Checkout Newsletter’. This is my settings:
Enable => yes
Checked by default => yes
Visible to guest => yes
Visible to registrant => yes
Now when you checkout you will see a check-box to sign-up for newsletter.
How to shift this module to your live cart?
Since, I couldn’t use the Magento Connect Manager on my live cart I FTP-ed these files:
(The name of the module is checkoutnewsletter and the company that created it is Desitex)
1. Copy the file Desitex_Checkoutnewsletter.xml from the app/etc/modules folder
2. Copy the folder Desitex from app/code/community folder
3. Copy the folder checkoutnewsletter from the app/design/frontend/default/default/template folder
4. Copy the file checkoutnewsletter.xml  from the app/design/frontend/default/default/layout folder
5. Login into the admin area and clear the cache.
To configure the module, follow the same steps as for the localhost cart.
Thats it!
[Edit]
Thanks to Brady, I took a closer look at the module. The module will break for Magento ver 1.4 beta1 and above – here is the fix:
Open the file:
[magento-root]/app/code/community/Desitex/Checkoutnewsletter/Model/Observer.php
On line number 10 change:
case Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER:
to
case ‘register’:
On line number 14 change:
case Mage_Sales_Model_Quote::CHECKOUT_METHOD_GUEST:
to
case ‘guest’:
The use of these 2 constants became deprecated since Magento 1.4 beta1

, , ,

23
Apr

Ok, so you have a nice custom module with a form – now you want to add basic javascript validation to it. Simple. Example,

<input type="text" name="first_name" value="" size="20" class="required-entry input-text" />

The class required-entry will make the field mandatory – this works for text-box and drop down.

If your form appears on the “one page checkout” page then, this is all you need to do.

If your form appears on its own then you will need to add this code at the bottom of your page:

<script type="text/javascript">
var customForm = new VarienForm('my-form-id');
</script>

Ensure that your form name and id are the same and that is what you need to pass to VarienForm

,