<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2758614826575627716</id><updated>2012-01-18T22:50:57.792-08:00</updated><category term='product options'/><category term='magento'/><category term='modification'/><title type='text'>Magento Developer Information</title><subtitle type='html'>Tutorials and code snippets for customizing Magento ecommerce.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://magentodev.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2758614826575627716/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://magentodev.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Brian</name><uri>http://www.blogger.com/profile/02421842015885198698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2758614826575627716.post-2609671933917107330</id><published>2009-05-18T14:34:00.000-07:00</published><updated>2009-05-18T15:21:34.519-07:00</updated><title type='text'>Magento: slow product updates</title><content type='html'>Ever since I upgraded to 1.3.1 simply saving a product takes a very long time (2-3 minutes). This was driving me (and others updating products) crazy.&lt;br /&gt;&lt;br /&gt;I finally resolved the issue. I was reviewing the MySQL processlist while magento was updating a product and noticed a very long running thread:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;invalidating query cache entries (key)   DELETE FROM `catalogindex_aggregation` WHERE (aggregation_id IN (SELECT `catalogindex_aggregation_to&lt;br /&gt;&lt;/pre&gt;I had enabled query caching per this&lt;a href="http://www.magentocommerce.com/group/blog/action/viewpost/393/group/227/"&gt; post&lt;/a&gt; on the magento groups. When I disabled query caching in MySQL the slow product updates issue disappeared. Now saving a product only takes 2-3 seconds.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2758614826575627716-2609671933917107330?l=magentodev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://magentodev.blogspot.com/feeds/2609671933917107330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://magentodev.blogspot.com/2009/05/slow-product-updates.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2758614826575627716/posts/default/2609671933917107330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2758614826575627716/posts/default/2609671933917107330'/><link rel='alternate' type='text/html' href='http://magentodev.blogspot.com/2009/05/slow-product-updates.html' title='Magento: slow product updates'/><author><name>Brian</name><uri>http://www.blogger.com/profile/02421842015885198698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2758614826575627716.post-1955217496252965459</id><published>2009-05-07T09:12:00.000-07:00</published><updated>2009-05-15T09:13:53.412-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='magento'/><category scheme='http://www.blogger.com/atom/ns#' term='product options'/><category scheme='http://www.blogger.com/atom/ns#' term='modification'/><title type='text'>How to import products with custom options in Magento</title><content type='html'>Over the past several months I've been using Magento on four stores. I've run into a few things which have required slight modifications.&lt;br /&gt;&lt;br /&gt;Recently I needed to import 200 new products. The products all had between 3 and 4 options. The default Magento import does not allow you to import custom options for products so I customized the import to allow imporing of options.&lt;br /&gt;&lt;br /&gt;To add this customization to your magento store first copy app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php to app/code/local/Mage/Catalog/Model/Convert/Adapter/Product.php. This will prevent upgrades from overwriting your changes.&lt;br /&gt;&lt;br /&gt;Next you need to add some code to "local" version of Product.php (code/local/Mage/Catalog/Model/Convert/Adapter/Product.php).  The line numbers below correspond to version 1.3 they may be a bit different in older versions.&lt;br /&gt;&lt;br /&gt;At about line 566 you will see:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;        foreach ($importData as $field =&gt; $value) {&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Just above that add:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;        $custom_options = array();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;At about line 575 you will see:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;$attribute = $this-&gt;getAttribute($field);&lt;br /&gt;if (!$attribute) {&lt;br /&gt;continue;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You will need to add some code above the continue statement.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;/* CUSTOM OPTION CODE */&lt;br /&gt;if(strpos($field,':')!==FALSE &amp;&amp; strlen($value)) {&lt;br /&gt;   $values=explode('|',$value);&lt;br /&gt;   if(count($values)&gt;0) {&lt;br /&gt;      @list($title,$type,$is_required,$sort_order) = explode(':',$field);&lt;br /&gt;      $title = ucfirst(str_replace('_',' ',$title));&lt;br /&gt;      $custom_options[] = array(&lt;br /&gt;         'is_delete'=&gt;0,&lt;br /&gt;         'title'=&gt;$title,&lt;br /&gt;         'previous_group'=&gt;'',&lt;br /&gt;         'previous_type'=&gt;'',&lt;br /&gt;         'type'=&gt;$type,&lt;br /&gt;         'is_require'=&gt;$is_required,&lt;br /&gt;         'sort_order'=&gt;$sort_order,&lt;br /&gt;         'values'=&gt;array()&lt;br /&gt;      );&lt;br /&gt;      foreach($values as $v) {&lt;br /&gt;         $parts = explode(':',$v);&lt;br /&gt;         $title = $parts[0];&lt;br /&gt;         if(count($parts)&gt;1) {&lt;br /&gt;            $price_type = $parts[1];&lt;br /&gt;         } else {&lt;br /&gt;            $price_type = 'fixed';&lt;br /&gt;         }&lt;br /&gt;         if(count($parts)&gt;2) {&lt;br /&gt;            $price = $parts[2];&lt;br /&gt;         } else {&lt;br /&gt;            $price =0;&lt;br /&gt;         }&lt;br /&gt;         if(count($parts)&gt;3) {&lt;br /&gt;            $sku = $parts[3];&lt;br /&gt;         } else {&lt;br /&gt;            $sku='';&lt;br /&gt;         }&lt;br /&gt;         if(count($parts)&gt;4) {&lt;br /&gt;            $sort_order = $parts[4];&lt;br /&gt;         } else {&lt;br /&gt;            $sort_order = 0;&lt;br /&gt;         }&lt;br /&gt;         switch($type) {&lt;br /&gt;            case 'file':&lt;br /&gt;               /* TODO */&lt;br /&gt;               break;&lt;br /&gt;               &lt;br /&gt;            case 'field':&lt;br /&gt;            case 'area':&lt;br /&gt;               $custom_options[count($custom_options) - 1]['max_characters'] = $sort_order;&lt;br /&gt;               /* NO BREAK */&lt;br /&gt;               &lt;br /&gt;            case 'date':&lt;br /&gt;            case 'date_time':&lt;br /&gt;            case 'time':&lt;br /&gt;               $custom_options[count($custom_options) - 1]['price_type'] = $price_type;&lt;br /&gt;               $custom_options[count($custom_options) - 1]['price'] = $price;&lt;br /&gt;               $custom_options[count($custom_options) - 1]['sku'] = $sku;&lt;br /&gt;               break;&lt;br /&gt;                                          &lt;br /&gt;            case 'drop_down':&lt;br /&gt;            case 'radio':&lt;br /&gt;            case 'checkbox':&lt;br /&gt;            case 'multiple':&lt;br /&gt;            default:&lt;br /&gt;               $custom_options[count($custom_options) - 1]['values'][]=array(&lt;br /&gt;                  'is_delete'=&gt;0,&lt;br /&gt;                  'title'=&gt;$title,&lt;br /&gt;                  'option_type_id'=&gt;-1,&lt;br /&gt;                  'price_type'=&gt;$price_type,&lt;br /&gt;                  'price'=&gt;$price,&lt;br /&gt;                  'sku'=&gt;$sku,&lt;br /&gt;                  'sort_order'=&gt;$sort_order,&lt;br /&gt;               );&lt;br /&gt;               break;&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;/* END CUSTOM OPTION CODE */&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now further on in the code (about line 710) you'll see $product-&gt;save(); Just after this add the following code:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;/* Remove existing custom options attached to the product */&lt;br /&gt;foreach ($product-&gt;getOptions() as $o) {&lt;br /&gt;   $o-&gt;getValueInstance()-&gt;deleteValue($o-&gt;getId());&lt;br /&gt;   $o-&gt;deletePrices($o-&gt;getId());&lt;br /&gt;   $o-&gt;deleteTitles($o-&gt;getId());&lt;br /&gt;   $o-&gt;delete();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* Add the custom options specified in the CSV import file */&lt;br /&gt;if(count($custom_options)) {&lt;br /&gt;   foreach($custom_options as $option) {&lt;br /&gt;      try {&lt;br /&gt;        $opt = Mage::getModel('catalog/product_option');&lt;br /&gt;        $opt-&gt;setProduct($product);&lt;br /&gt;        $opt-&gt;addOption($option);&lt;br /&gt;        $opt-&gt;saveOptions();&lt;br /&gt;      }&lt;br /&gt;      catch (Exception $e) {}&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;That's it, you should be all set to import custom product options.&lt;br /&gt;&lt;br /&gt;To import a custom option you need to add a new column to your CSV import file. The name of the column determines the name and type of the option. The format is: Name:Type:Is Required. For example, to create a required drop down option called "Size" your column header should be: Size:drop_down:1 (1 for required, 0 for optional). Here is a list of the Types, these are taken from the "Custom Options" screen in the Magento admin area.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;field: Field&lt;/li&gt;&lt;li&gt;area: Area&lt;/li&gt;&lt;li&gt;file: File&lt;/li&gt;&lt;li&gt;drop_down: Drop-down&lt;/li&gt;&lt;li&gt;radio: Radio Buttons&lt;/li&gt;&lt;li&gt;checkbox: Checkbox&lt;/li&gt;&lt;li&gt;multiple: Multiple Select&lt;/li&gt;&lt;li&gt;date: Date&lt;/li&gt;&lt;li&gt;date_time: Date &amp;amp; Time&lt;/li&gt;&lt;li&gt;time: Time&lt;/li&gt;&lt;/ul&gt;For types with multiple values (drop_down, radio, checkbox, multiple) you can specify using a | separator. Example for Small, Medium, Large you would use "Small|Medium|Large" as the value for the "Size:drop_down:1" column in your csv file.&lt;br /&gt;&lt;br /&gt;Here's paired down example of the import format:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;sku,name,description,price,Size:drop_down:1&lt;br /&gt;T-Shirt1,T-Shirt,A T-Shirt,5.00,Small|Medium|Large&lt;br /&gt;T-Shirt2,T-Shirt2,Another T-Shirt,6.00,XS|S|M|L|XL&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In addition you can specify an addition price and SKU modifier for each option value. The syntax for this is Value:[fixed|percent]:price_modifier. For example if you have a product which costs $5 more for a Medium and $10 more for a large you would the following as the option value.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;Small|Medium:fixed:5|Large:fixed:10&lt;/pre&gt;&lt;br /&gt;Here's the first example with additional price/sku modifiers.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;sku,name,description,price,Size:drop_down:1&lt;br /&gt;T-Shirt1,T-Shirt,A T-Shirt,5.00,Small:fixed:0:-SM|Medium:percent:2:-MED|Large:percent:3:-LRG&lt;br /&gt;T-Shirt2,T-Shirt2,Another T-Shirt,6.00,XS:fixed:0:-XS|S:fixed:0:-S|M:fixed:1:-M|L:fixed:1:-L|XL:fixed:2:-XL&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;UPDATE: 5/12&lt;br /&gt;Here's a sample CSV file I used to test code additions by @gancheff and @Brendan.&lt;br /&gt;&lt;iframe width="700" height="350" frameborder="0" scrolling="no" src="http://sheet.zoho.com/publish/brianmoney/import-sample"&gt; &lt;/iframe&gt;&lt;br /&gt;&lt;br /&gt;I hope this modification helps others who need to import product options.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2758614826575627716-1955217496252965459?l=magentodev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://magentodev.blogspot.com/feeds/1955217496252965459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://magentodev.blogspot.com/2009/05/how-to-import-products-with-custom.html#comment-form' title='154 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2758614826575627716/posts/default/1955217496252965459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2758614826575627716/posts/default/1955217496252965459'/><link rel='alternate' type='text/html' href='http://magentodev.blogspot.com/2009/05/how-to-import-products-with-custom.html' title='How to import products with custom options in Magento'/><author><name>Brian</name><uri>http://www.blogger.com/profile/02421842015885198698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>154</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2758614826575627716.post-3009014749145826338</id><published>2009-03-11T14:46:00.000-07:00</published><updated>2009-03-11T15:01:48.001-07:00</updated><title type='text'>Magento VMWare Virtual Appliance</title><content type='html'>This is the first post on my Magento blog. I've been using Magento on 4 sites for the past month and wanted to start sharing what I've learned.&lt;br /&gt;&lt;br /&gt;Magento is an extremely flexible ecommerce system, but it can be a bit tricky to install. I've created a VMWare LAMP&lt;a href="http://www.bigdeelz.com/upload/MagentoVA.zip"&gt; virtual appliance&lt;/a&gt; with Magento 1.2.1.2 pre-installed so that others can easily experiment with Magento. The virtual appliance is built on Centos 5.2 and has all necessary PHP modules pre-installed.&lt;br /&gt;&lt;br /&gt;You'll need either VMWare Server or Player, both are free and can be downloaded from http://www.vmware.com.  When you load up the &lt;a href="http://www.bigdeelz.com/upload/MagentoVA.zip"&gt;virtual appliance&lt;/a&gt;, it will display it's IP address on the console, open the IP in your web browser and complete the install. You can then access the sample store at the IP of the virtual machine.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2758614826575627716-3009014749145826338?l=magentodev.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://magentodev.blogspot.com/feeds/3009014749145826338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://magentodev.blogspot.com/2009/03/magento-vmware-virtual-appliance.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2758614826575627716/posts/default/3009014749145826338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2758614826575627716/posts/default/3009014749145826338'/><link rel='alternate' type='text/html' href='http://magentodev.blogspot.com/2009/03/magento-vmware-virtual-appliance.html' title='Magento VMWare Virtual Appliance'/><author><name>Brian</name><uri>http://www.blogger.com/profile/02421842015885198698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry></feed>
