Magento place order slow [FIXED]

The Magento “place order” step can take up to a minute. With thanks to this site I figured out how to fix slow checkouts.

Step 1

Find the file app/code/core/Mage/Rss/etc/config.xml and uncomment/remove:

<sales_order_save_after>
<observers>
<notifystock>
<class>rss/observer</class>
<method>salesOrderItemSaveAfterNotifyStock</method>
</notifystock>
</observers>
</sales_order_save_after>
<sales_order_save_after>
<observers>
<ordernew>
<class>rss/observer</class>
<method>salesOrderItemSaveAfterOrderNew</method>
</ordernew>
</observers>
</sales_order_save_after>

Step 2

Find the file app/code/core/Mage/Downloadable/etc/config.xml and uncomment/remove:

<!–sales_order_item_save_commit_after>
<observers>
<downloadable_observer>
<class>downloadable/observer</class>
<method>saveDownloadableOrderItem</method>
</downloadable_observer>
</observers>
</sales_order_item_save_commit_after–>

sqlstate 23000 integrity constraint violation 1048 column ‘value’ cannot be null magento

How to solve the problem ‘sqlstate 23000 integrity constraint violation 1048 column ‘value’ cannot be null magento’?

This problem is quite hard to identificate, because it’s hard to seek the right column ‘value’. Here is what I did in order to find out the problem.

  • Start the import process and see on which record number the errors occur.
  • Locate these record numbers and find the difference between other records in a spreadsheet program.
  • In my example I found out that on some rows the meta_robots column was empty instead of INDEX, FOLLOW. This caused the error.
  • Fill these rows. This will solve the problem.

BTW verhoging 21 procent doorvoeren in Magento (dutch)

Het kan de meeste mensen inmiddels niet ontgaan zijn, per 1 oktober 2012 zal er een BTW verhoging ingaan van 19 naar 21 procent. Vervelend daarbij is dat er nogal wat onduidelijkheden zijn. Aangezien ik zelf verstand heb van het webwinkel pakket Magento, probeer ik in dit artikel alle onduidelijkheden omtrent het nieuwe BTW tarief de wereld uit te helpen. U kunt daarbij zelf kiezen of u de BTW in de prijs door wilt voeren liever niet.

Stap 1: BTW tarief verhogen

Dit kunt u doen bij Verkopen > BTW > Beheer Belastingzones en Tarieven

Stap 2a: BTW in de prijs door laten voeren (prijsverhoging)

Hier komt een technisch verhaal bij kijken. De bedoeling is dat de catalogusprijs met de stijging van het btw-niveau automatisch meegaat. Uitgerekend is dit een prijsstijging van 1,68% (aan de hand van (1/119)*121*100% ). De bedoeling is dus om een negatieve korting te geven op alle producten.

Magento accepteert echter standaard geen negatieve kortingen:

Magento Negatieve Korting

 

 

Conform het volgende artikel moeten we dus een paar wijzigingen doorvoeren in de kern:

  1. Ga naar: app/code/core/Mage/Rule/Model/Rule.php en vind:
    //check if discount amount > 0
    if ((int)$this->getDiscountAmount() < 0) { 3 Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount amount.’));
    }
  2. Vervang deze code door deze uit te 'commenten':
    // if ((int)$this->getDiscountAmount() < 0) { 3 //Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount //amount.’));
    //}
  3. Ga nu naar: app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Actions.php en vind: 'class' => 'validate-not-negative-number',
  4. ‘Comment’ deze code ook uit: // 'class' => 'validate-not-negative-number',
  5. Herhaal stap 3 en 4 voor het bestand app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Actions.php
  6. Verander in het bestand app/code/local/Mage/CatalogRule/Model/Observer.php :
    $finalPrice = min($product->getData(‘final_price’), $this->_rulePrices[$key]);
    in:
    $finalPrice = $this->_rulePrices[$key];
  7. Vervolgens kunt u deze bestanden uploaden (het veiligste is om de bestanden niet in app/code/core, maar app/code/local op te slaan).
Vervolgens kunt u de negatieve korting doorvoeren.
Ga naar promotie > catalogus prijsregels > nieuwe regel aanmaken. Geef de prijsregel een naam en voer bij actie het tarief van -1,68 procent in. Daarbij kunt u een vanaf datum van 1 oktober 2012 instellen. Vervolgens kunt u de wijzigingen opslaan en klikt u op ‘apply rules’.
Het nadeel van een automatische stijging is wel dat een ‘mooie’ prijs als €49,95 zal vanderen in €55,21. Mocht u later dus alle prijzen handmatig wijzigen, kunt u de zojuist ingevoerde prijsregel weer uitzetten.

Stap 2b: BTW niet in de prijs door laten voeren (gelijke prijs)

Als het goed is, is hier verder geen wijziging voor nodig.

Extra fee for Shopping Cart AND Catalog Cart Price Rules in Magento – Negative discount

This article is incomplete and the solution might not work!

Ever wondered wether it would be possible creating a negative discount? This article describes how to create a negative shopping cart price rule.

By default, Magento doesn’t accept negative price rule discount values:

Magento Negatieve Korting

We have to add some changes through the core in Magento conform the article:

  1. Go to: app/code/core/Mage/Rule/Model/Rule.php and fin:
    //check if discount amount > 0
    if ((int)$this->getDiscountAmount() < 0) { 3 Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount amount.’));
    }
  2. Replace this code, by 'commenting':
    // if ((int)$this->getDiscountAmount() < 0) { 3 //Mage::throwException(Mage::helper(‘rule’)->__(‘Invalid discount //amount.’));
    //}
  3. Go to: app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab and find: 'class' => 'validate-not-negative-number',
  4. ‘Comment’ this code as well: // 'class' => 'validate-not-negative-number',
Now it works for shopping cart price rules. Unfortunately the article doesn’t describe how to enable negative values for catalog price rules. We have the solution:
  1. Repeat step 3 and 4 for the file app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit/Tab/Action.php
  2. Then you can upload these files, I’ll prefer to save it in the app/code/local directory instead of core.

Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

When having trouble with the error: “Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction” or when your place order / order confirmation gets stuck.

Fixing the order process getting stuck:

According to the Magento Forum, in MySQL, try:

TRUNCATE `log_customer`;
TRUNCATE `log_quote`;
TRUNCATE `log_summary`;
TRUNCATE `log_summary_type`;
TRUNCATE `log_url`;
TRUNCATE `log_url_info`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;

Of course create a backup first. Doesn’t this fix the problem or do you have a better solution? Comment it!

Change the ‘add to cart’ button to ‘view product’ in Magento on category page

So you’ve got your webshop with products with different sizes. The ‘add to cart’ button on the category page is sometimes a step too much, because you’ll have to choose a size first.

Changing the button to ‘view product’

Changing the button to ‘view product’ would be a better solution. Open the file list.phtml in: /app/design/frontend/default/{yourskin}/template/catalog/product .

About line 63 and about line 107 replace: <p><button type=”button” title=”<?php echo $this->__(‘Add to Cart’) ?>” onclick=”setLocation(‘<?php echo $this->getAddToCartUrl($_product) ?>’)”><span><span><?php echo $this->__(‘Add to Cart’) ?></span></span></button></p>

With:

<button type=”button” title=”<?php echo $this->__(‘Add to Cart’) ?>” onclick=”setLocation(‘<?php echo $_product->getProductUrl() ?>’)”><span><span>View product</span></span></button>

Magento – Detect if a customer/user is logged in

Ever wondered if it’s possible enabling special features in phtml for logged in clients? Yes, it’s possible. Just with a simple if/else statement.

<?php
if ($this->helper('customer')->isLoggedIn()) {
    echo "Special content for customers";
else {
    echo "The special content is not visible for you, login first.";
}
?>

Now you’re able to display for example your price only to customer that are logged in or give customers that are logged in a discount code.

Creating a contact page with contact information and form

Standard the contact page only has an contact form and lacks contact information. You can fix this as follow:

  1. Create a new page in the admin -> CMS -> Pages
  2. Insert your contact information. In order to insert the contact form, use the following code:

    {{block type=”core/template” name=”contactForm” form_action=”/contacts/index/post” template=”contacts/form.phtml”}}

  3. Save your page and link to this contact page.
  4. Your contact page is finished!

Adding a Magento Blog Feature to your webshop

Magento Blog Plugin
Nice example of a Magento Blog

A blog is an important factor in respect to SEO for your webshop. Unfortunately the Magento Community Edition doesn’t offer a blog feature.

Fortunately Aheadworks created a plugin that creates a blog for Magento. It’s easily implementable with Magento Connect. Download it.

Install it and clear the cache.

Setting up the blog

Go to: Admin -> System -> Configuration -> Aheadworks -> Blog.

At the enable dropdown, choose ‘yes’. The blog is enabled now. Set up a ‘blog title’ and a ‘route to blog’. Go to YOURWEBSITE.COM/YOURROUTETOBLOG . If everything is alright, the blog should work. Else, try to remove the cache / refresh indices.

At Blog -> Add post you can add new blogposts.

Common problems

The admin shows a blank page when opening the plugin

It’s easy to fix this. Log out from the admin panel, clear the cache, login and open the plugin again. It should work.

Creating discount for your customers in Magento

Ever wondered how to set up discount for your customers? Here’s a how to guide:

Discount based on a coupon code

1. So you would like to create a discount based on a coupon code? Log in to your admin, go to promotions -> shopping cart pricerules and click on ‘add new pricerule’. Give the rule a name.

2. Select all discount groups with ctrl or shift. Select ‘specific coupon’ on the dropdown and at ‘discount code’ enter your discount code.

You can specify an end date as well at ’till date’.

Don’t want to use coupon code?

If you don’t want to use a coupon code, skip step 2.

Discount amount

Navigate to the tab ‘actions’ and at the field ‘discount amount’ enter the amount of discount you would like to give with the coupon. You can choose a fixed amount or a percentage at the dropdown ‘apply’.