Rss Feed Tweeter button Facebook button Technorati button Reddit button Myspace button Delicious button Digg button

Fix Magento Error Cannot add the item to shopping cart

Currently trying out multiple websites function in Magento, which is unfortunately not a straightforward process.

Kept encountering the error Cannot add the item to shopping cart with the second website. It works in the catalogue grid but in the product view it will not add the item to the cart.

After a lot of digging around the problem seems to be that the second website cannot access the cache.

Fix:

  • Create a new directory called tmp in the home directory of the second website.
  • Edit /lib/Zend/Cache/Backend/File.php
  • change ‘cache_dir’ => null, to ‘cache_dir’ => “tmp/”,
  • ensure there it a directory tmp in your original root installation also.

Update

There is a better way to do it and one which does not involve editing core files. It is also simpler:

  • System->Configuration->Web->Session Cookie management
  • change value from 3600 to 86400

Fix for Magento Error in IE9 Additional Information tabs not working.

I noticed the additional information tags in Magento stopped working – the lightbox opened over the page when clicked upon.

I removed Magento Easy Lightbox Community Module but now the information tab does nothing.

The pages work fine in Firefox but IE9 doesn’t appear to like the part of the javascript  and the developer console gives an error.

I was not able to fix it so as a work around used:

<meta http-equiv=”X-UA-Compatible” content=”IE=7″/>

in the head section of the page. From memory this is located in \app\design\frontend\base\default\template\page\html\head.phtml

Back to working properly again.

How to Restrict Quantity of Items in Magento

I have been looking at how to stop checkout of maximum quantities in Magento for one product category e.g. one per transaction or one per customer only.

The short answer: it’s not possible (unless you want to pay for a commercial extension).

The workaround

Scenario: I am starting a penny sale – simply pay for postage and packaging and buy something for 1p, or add a penny item to your order.

Orders from the penny sale category will be restricted to one per transaction. As this is not possible I have decided on a surcharge instead.

This has the benefit of allowing customers to decide if they wish to purchase more than one and allows the retailer to use existing Magento tools.

We are going to use Shopping Cart Price Rules (under the promotions tab from the dashboard). If the customer purchases more than one item from the category then £1 will be added for the second and each additional item in the shoppping cart.

By default a surcharge (or negative discount) is not allowed in Magento so we need to change a few lines of code to enable it:

1. Go to app/code/core/Mage/Rule/Model/Rule.php

Find the line:

//check if discount amount > 0
if ((int)$this->getDiscountAmount() < 0) {
Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount amount.’));
}

Just add some bars // to comment the code:

//check if discount amount > 0
//if ((int)$this->getDiscountAmount() < 0) {
//Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount amount.’));
//}

2. Now go to: app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php

Look for:

$fieldset->addField(‘discount_amount’, ‘text’, array(
‘name’ => ‘discount_amount’,
‘required’ => true,
‘class’ => ‘validate-not-negative-number’,
‘label’ => Mage::helper(’salesrule’)->__(‘Discount amount’),

And again comment like this:

$fieldset->addField(‘discount_amount’, ‘text’, array(
‘name’ => ‘discount_amount’,
‘required’ => true,
// ‘class’ => ‘validate-not-negative-number’,
‘label’ => Mage::helper(’salesrule’)->__(‘Discount amount’),

3. Translate the discount word.

Go to app/locale/en_US

Find a file called Mage_Sales.csv. Inside look for the word discount you will find something like:

“Discount (%s)”,”Discount (%s)”
Change the text to what ever you like, e.g.:
“Discount (%s)”,”Extra Fee (%s)”

The above section comes from: http://php.quicoto.com/extra-fee-shopping-cart-price-rules-magento/

 

Next we need to create the shopping cart rule by setting the conditions:

My sale catgegory is 55 so I want to activate the rule when more than one item from category 55 is added to the cart.

 

Then we need to create the actions rule to tell Magento what to do when the above conditions are met:

You will notice I have added an extra condition in the actions section. This is to ensure only items in category 55 attract the £1 surcharge – without it £1 would be added for every item in the shopping cart.

It is not quite how I wanted it to work as it add £1 for every item in the basket if rather than only for the second one, third one etc, but it will have to do.

Whilest it is unfortunate that the rules in Magento are not more flexible or easier to customise, after hours or research this is the simplest and quickest workaround I have found.

Change Magento Category Image Size

For some reason category images were being expanded to fit the column size.

Instead of a 100px picture customers would see it expanded to 520px.

To fix it, edit the style sheet:

/skin/frontend/default/YOURTEMPLATENAME/css/styles.css

Look for the value category-image.

I made the following changes to mine:

  • change the alignment to left at the end of the first line – previously it was center
  • delete the end of the second line – previously it was width 100%

.category-image { width:100%; overflow:hidden; margin:0 0 10px; text-align:left; }
.category-image img

Magento Remove Back to School and The Dog

Those pointless and annoying callouts in Magento! Back to School and the Dog call us on (555) 555-0123. Every Magento user is familiar with these side boxes.

I found the simplest way to remove them is to rename the call out files so their functions no longer exist.

/app/design/frontend/base/default/template/callouts

rename the two files by putting something in front of them e.g.:

STOPleft_col.phtml

STOPright_col.phtml

Pointless call-outs gone!

Export ZenCart products, Import Magento products: Summary

Here is a summary of the CSV file downloaded from ZenCart, edited then uploaded to Magento.

If you are new to Magento you may wish to read first my previous posts on importing basic products into Magento from ZenCart, configuring the Magento CSV file and importing categories and images.

Overview:

Creating a Magento product CSV from a ZenCart file is straightforward and easy.

I open a sample Magento file and then copy and paste the Zen-cart columns, deleting the column when it is copied over to keep track.

Then simply bulk copy and paste the remaining Magento specific rows – it only takes about 4 copy and pastes. Change the image details then sort out the categories. Upload and done.

Magento Headings    Information Required               ZenCart Equivalent

store                            default: admin

websites                    name of every website using this product

eg myweb1, myweb 2 (comma separated)

attribute                    Default

type                             simple

category_ids           the number of the category     v_categories_name_2

simply find and replace to convert them

sku                               model number/stock code       v_products_model

has_options             0

name                            product name                          v_products_name_1

meta_title  meta_description   url_key url_path page_layout options_container

I leave all these blank although you could copy and paste them from your ZenCart database if you wanted.

gift_message_available  default: Use config

price                            cost for buyers                                    v_products_price

special_price  /  cost    I leave these 2 blank

weight                         weight for shipping purposes  v_products_weight

status                          Enabled           ensure this is set for all products else they do not show

tax_class_id            Taxable Goods

is_recurring             No

visibility                   Catalog, Search

enable_googlecheckout           set all to Yes or No if you want to use Google checkout

description              product description                 v_products_description_1

short_description     either copy in description again or leave blank (I leave it blank)

meta_keyword custom_layout_update  special_from_date   special_to_date news_from_date news_to_date            custom_design_from  custom_design_to

I leave all these blank

qty                              number in stock                       v_products_quantity

The following depend on your set up. Most will be 0 or 1. Below is mine:

min_qty                    0

use_config               1

is_qty_decimal       0

backorders              0

use_config_backorders           1

min_sale_qty         1

use_config_min_sale_qty       1

max_sale_qty        0

use_config_max_sale_qty       1

is_in_stock              1

low_stock_date     ( I leave this blank)

notify_stock_qty     0

use_config_             1

manage_stock        0

use_config_manage_stock      1

stock_status_changed_automatically 0

use_config_qty_increments    1

qty_increments     0

use_config_enable_qty_increments    1

enable_qty_increments           0

product_name             I don’t know why this appears again copy  and paste column H name

store_id                     1

product_type_id   simple

product_status_changed         I leave this blank

product_changed_websites    I leave this blank

image                          /image.jpg        v_products_image

Use the image name with the / and ensure jpg is lower case.  If you have directoryname/image.jpg then simply find and replace all directoryname/ with / to leave /image.jpg

Copy all the image files to /media/import and ensure permission on the files is 777.

small_image            copy and paste column from image

thumbnail                 copy and paste column from image

Export ZenCart products, Import Magento products Part 2

Once your products are in Magento you will probably want to change settings.

For example all my products had a quantity of 0 and were not visible or included in searches. To get started quickly I want to change everything to in stock and display the items in the search and catalogue.

Once again we can do this by exporting and importing a file rather than go through everything individually.

Change 1 item to the way you want it by editing the first product on the page.

Catalogue>Manage products>Edit a product.

For one product I changed the following in the product edit from the menu on the right hand side:

General: Status to Enabled, Visibility to Catalogue, Search

Prices: Tax Class

Inventory:  Quantity, In stock yes.

These are the basics but your item will still not show in Magento. You need to assign the product to your website, or store view even if you only have 1 website/view. This is by using the catalogue, products menu, ticking the box by the product and updating attributes then using the websites option.

I found a detailed explanation of it here: how to display products in Magento and assign products to a store view. They also show a video on where to click if you are not sure what to do.

This is another example of the strange quirks of Magento and how user unfriendly it is. Now we know how to do it and have a product in better shape, lets export the file.

System> Import/Export Profiles>Export All Products>Run Profile

The file is found on the server var/export.

The first product should now have all the values in the columns set up correctly so its simple a case of copy and pasting those values in excel.

My changes to copy and paste down the columns are :

B websites

T status, U tax_class_id, V is_recurring, W visibilty, X eenable_googlecheckout

As these are helpfully together in one block we can copy the whole row from T to X and paste is downwards. I changed all mine to:

Enabled Taxable Goods No Catalog, Search Yes

I have also taken this opportunity to once again paste the stock quantity in from the Zencart file. Ensure the is_in_stock column is all set to 1.

Save the file then re-import it as shown in previously in part 1 importing products to Magento from Zencart.

Products should now be in stock, enblesd, searchalble and showing on your site.

Next I shall be making categories and assigning products to categories using the same export/edit/import method.

Removing the Help Us to Keep Magento Healthy Message in Magento 1.4

Before starting your edits turn off the cache.

The footer message is really annoying.

There is a footer function in admin to configure but the bug reporting message is coded into the files, not through the admin/backend.

I don’t know why the developers make it so difficult to use. I realise it is a community edition yet should a free product should be an example of what the paid for item can do. It should shine and stand out from the crowd, be a call to upgrade, a beacon for others to set their standards, the start of a new relationship? Not a pain that makes you want to look elsewhere.

However, I found the answer

/app/design/frontend/base/default/template/page/html/footer.phtml

Mine looks like this:

<div class=”footer-container”>
<div class=”footer”>
<div ?php echo $this->getChildHtml() ?>
</div>
</div>

Turn the cache back on
Why not take this opportunity to change the footer copyright to something of your choice?
This can be found in the system/configuration menu. Select design on the left then fill out the footer parts as required.

NB: I am currently testing the modern theme so to remove the magento bugs message edit the footer  file in app\design\frontend\default\modern\template\page\html

Simply remove the whole ‘p class bugs’ line.