Saturday, August 27, 2011

Magento events: Cheat Sheet

This post is for me as well as for everyone else who is always looking for the Magento events.

My personal favorite is from Mastering Magento:

http://masteringmagento.com/2010/06/events-list-in-magento-community-1-4/

The section that I found most helpful is this

$this->_eventPrefix.'_add_is_active_filter
$this->_eventPrefix.'_delete_after
$this->_eventPrefix.'_delete_after_done
$this->_eventPrefix.'_delete_before
$this->_eventPrefix.'_delete_commit_after
$this->_eventPrefix . '_load_after
$this->_eventPrefix.'_load_after
$this->_eventPrefix . '_load_before
$this->_eventPrefix.'_move_after
$this->_eventPrefix.'_move_before
$this->_eventPrefix.'_'.$process.'_process_run_after
$this->_eventPrefix.'_'.$process.'_process_run_before
$this->_eventPrefix.'_save_after
$this->_eventPrefix.'_save_before
$this->_eventPrefix.'_save_commit_after
$this->_eventPrefix.'_validate_after
$this->_eventPrefix.'_validate_before

What we can do is take the event prefix from the list below and attach the action after. So for example you catalog_product event you want to do something after you simple do catalog_product_save_after. This is in no way a comprehensive list. The website Mastering Magento does offer a script to generate the Magento Events on your Linux server (I have not tried it)

admin_roles
 admin_user
 catalog_category
 catalog_category_collection
 catalog_compare_item
 catalog_entity_attribute
 cataloginventory_stock_item
 catalog_product
 catalogrule_rule
 cms_page
 core_abstract
 core_config_data
 customer
 customer_address
 customer_entity_attribute
 customer_group
 eav_entity_attribute
 eav_form_element
 eav_form_fieldset
 eav_form_type
 giftregisty_gift
 newsletter_subscriber
 review
 sales_creditmemo_item
 sales_invoice_item
 sales_order
 sales_order_creditmemo
 sales_order_invoice
 sales_order_item
 sales_order_shipment
 sales_order_shipment_track
 sales_quote
 sales_quote_address
 sales_quote_item
 sales_quote_payment
 salesrule_rule
 sales_shipment_item
 store
 store_group
 system_config_price_scope
 tag
 website
 wishlist_item

Nick Says has a very good list of Magento 1.5 Events here

http://www.nicksays.co.uk/magento_events_cheat_sheet/

Twitter: @brentwpeterson on Twitter
Linkedin: http://www.linkedin.com/in/brentwpeterson
View My Magento Profile

Tuesday, August 23, 2011

Magento errors SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry during upgrade

If you are upgrading your Magento store and you have received this error:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

The solution is to modify your /app/etc/config.xml file with the following:

Original statement
SET NAMES utf8

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

Twitter: @brentwpeterson on Twitter
Linkedin: http://www.linkedin.com/in/brentwpeterson
View My Magento Profile

Sunday, August 21, 2011

Upgrading your Magento install to version 1.6

I have been hanging out a lot on the Magento 1.6 upgrade boards and I have been seeing all sorts of problems with upgrading.

Short of trying to upgrade via a new install and going through all the work of transferring your themes etc you can do it via ssh

The following worked for me: (Remember if you are running on a machine with low resources and you have many products the script will take longer to run)

rm -rf var/cache var/session
chmod 550 ./mage
./mage mage-setup .
./mage config-set preferred_state stable
./mage list-installed
./mage list-upgrades
./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force
php shell/indexer.php reindexall

As always, your best resource for Magento information is the Magento site

You can access the 1.6 upgrade boards here

Twitter: @brentwpeterson on Twitter
Linkedin: http://www.linkedin.com/in/brentwpeterson
View My Magento Profile

Friday, August 19, 2011

Truncate Customer Log tables in Magento

To keep the size of you Magento Database small it helps to truncate your log tables.

The following is for MySQL access to truncate all data in your tables.

Always BACKUP first

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` ; 
TRUNCATE `log_visitor_online` ;

Twitter: @brentwpeterson on Twitter
Linkedin: http://www.linkedin.com/in/brentwpeterson
View My Magento Profile

The Windows 7 Dilemma

Windows vs. Mac

Welcome to my first Blog post. It seems that there has always been a divide between PC and Mac. I have always been on the PC side until recently...

Terminal Support

I love Windows 7, it is fast and mostly secure and offers nearly everything I need, except integrated Unix and there is my dilemma. My world now revolves around developing on LAMP and using a Windows box is more inconvenient than convenient. Using Putty is great and I find Cygwin exciting, but at the end of day they all have their shortcomings. I am using a Ubuntu (Soon to be Fedora) box at work now and I find I hardly ever turn to my PC. The simple fact that I spend most of my time in the command line is a big factor on why I want to switch.

Why not just go to Linux?

So I guess the next question has to be "Why not just switch to Linux?" The quick answer is that I would like to have access to mainstream programs that are only available for PC/Mac. So if I get a computer that has mainstream integration and has Unix support what do you choose? The answer seems simple.

Boot time

I rebooted my Windows 7 machine this morning, then went and took the trash out. When I first installed my machine I tried to make sure that I had only items I need, but as your machine gets older it loads more and more into start up. Wouldn't it be great if you didn't have to worry about that? Wouldn't it be great to have your machine ready to use in a couple of minutes?

Conclusion?

I think the verdict is still out, but I decided to look at the new Macbook Air. I think it will give me the portability and functionality that I want in a computer along with Mainstream support to use all the commercial programs I want to use.

I will keep you posted!

Twitter: @brentwpeterson on Twitter
Linkedin: http://www.linkedin.com/in/brentwpeterson
View My Magento Profile