Sunday, September 25

Magento : Image Upload Problem/Issue Magento 1.6

Hi Guys,

I figured out problem occurred with Magento image upload in version 1.6, for that I am posting a thread which can easily short the problem.

1. Download prototype.js version 1.6.0.3

2. Go to Magento/js/prototype – here rename prototype.js with prototype.js.BKP

3. Then copy downloaded prototype.js in Magento/js/prototype

4. In the /app/etc/config.xml file change the initStatements node from:

SET NAMES utf8

to:

SET NAMES utf8; SET FOREIGN_KEY_CHECKS=0; SET UNIQUE_CHECKS=0;

Flush the cache and then you can upload image for products.

That’s all, go to admin panel in Magento admin panel and upload and import product successfully.

Hope it Helps... Thanks....

Magento Free shipping on orders over $50

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.

Hope it Helps.. Thanks....

How to create an attribute in Magento?

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.

Hope it Helps... Thanks....

How to Change the Admin Password in Magento?

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

Hope it Helps... Tanks....

How to Add Multiple Products To The Cart Simultaneously

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/”);
?>

Hope it Helps... Thanks...

Tips to Creating Magento Products On-The-Fly

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.

<?php
require_once ‘app/Mage.php’;
Mage::app();
[/php] [php]
// instatiate Product
$product = Mage::getModel(‘catalog/product’);

$product->setWebsiteIds(array(1));
$product->setSku(‘rand-sku-’ . rand());
$product->setPrice(rand(100,2000));
$product->setAttributeSetId(4);
$product->setCategoryIds(array(3));
$product->setType(‘Simple Product’);
$product->setName(‘Product Name’.rand(1,200000));
$product->setDescription(‘The Product Description’);
$product->setShortDescription(‘Brief Description’);
$product->setStatus(1);
$product->setTaxClassId(‘2′);
$product->setWeight(0);
$product->setCreatedAt(strtotime(‘now’));

/* ADDITIONAL OPTIONS

$product->setCost();
$product->setInDepth();
$product->setKeywords();

*/

$product->save();

// "Stock Item" still required regardless of whether inventory
// control is used, or stock item error given at checkout!

$stockItem = Mage::getModel(’cataloginventory/stock_item’);
$stockItem->assignProduct($product);
$stockItem->setData(’is_in_stock’, 1);
$stockItem->setData(’stock_id’, 1);
$stockItem->setData(’store_id’, 1);
$stockItem->setData(’manage_stock’, 0);
$stockItem->setData(’use_config_manage_stock’, 0);
$stockItem->setData(’min_sale_qty’, 0);
$stockItem->setData(’use_config_min_sale_qty’, 0);
$stockItem->setData(’max_sale_qty’, 1000);
$stockItem->setData(’use_config_max_sale_qty’, 0);

$stockItem->save(); 
?>

hope it helps... thanks...

How to Use SQL Queries in Magento

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” ????

Try this syntax with your customization

$yourvariable = $layer->getProductCollection()->addAttributeToFilter(’special_price’,array(‘notnull’=>”));

I have used this to get only those products which has some special price assigned.

Hope it Helps... Thanks

How to upgrade magento to latest version

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-core/Interface_Adminhtml_Default
>> magento-core/Interface_Frontend_Default
>> magento-core/Interface_Install_Default
>> magento-core/Mage_Core_Adminhtml
>> magento-core/Mage_Core_Modules

Hope it Helps... Thanks....

How to upgrade magento from admin control panel

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.

Good luck with the upgrade!

Hope it Helps.. Thanks

How to move Cart from Right Sidebar to Header in Magento?

Here is the detailed steps to move the cart from right sidebar to header

Find the below line in your page.xml file.
<block as="header" name="header" type="page/html_header"> //Near line 70
</block>

Add the below code inside to that block
<block as="topcart" name="cart_sidebar" template="checkout/cart/sidebar.phtml" type="checkout/cart_sidebar">
</block>

Your new code will look like this
<block as="header" name="header" type="page/html_header">
        <block as="topLinks" name="top.links" type="page/template_links">
        <block as="store_language" name="store_language" template="page/switch/languages.phtml" type="page/switch">
        <block as="topMenu" name="top.menu" translate="label" type="core/text_list">
            <label>Navigation Bar</label>
        </block>
        <block as="topContainer" name="top.container" translate="label" type="page/html_wrapper">
            <label>Page Header</label>
            <action method="setElementClass"><value>top-container</value></action>
        </block>
 //new block 
 <block as="topcart" name="cart_sidebar" template="checkout/cart/sidebar.phtml" type="checkout/cart_sidebar">
</block>
</block></block></block>

Finally Add the below code in your "\template\page\html\header.phtml" file.
//place this where ever you want the cart to show up.
<?php echo $this->getChildHtml('topcart'); ?>

Thats it. You can see the cart sidebar in your header section.

Hope it Helps... Thanks....