{"id":155,"date":"2010-11-24T12:16:15","date_gmt":"2010-11-24T12:16:15","guid":{"rendered":"http:\/\/www.cotsweb.com\/blog\/?p=155"},"modified":"2010-11-24T12:16:15","modified_gmt":"2010-11-24T12:16:15","slug":"zen-cart-copying-product_type_layout-for-a-new-product_type","status":"publish","type":"post","link":"https:\/\/www.cotsweb.com\/blog\/zen-cart-copying-product_type_layout-for-a-new-product_type-155.html","title":{"rendered":"Zen Cart copying product_type_layout for a new product_type"},"content":{"rendered":"<p>I have been working on a new site for <a title=\"Limited Edition fine art prints\" href=\"http:\/\/www.globalartprints.co.uk\">Global Art Prints<\/a>.\u00a0 The site is an online shop selling Limited Edition prints, mainly by British artists. \u00a0 I have customised a <a title=\"Zen Cart eCommerce and Shopping Cart software\" href=\"http:\/\/www.zen-cart.com\/\">Zen Cart eCommerce<\/a> installation to suit the new shop.\u00a0 As part of the process I have needed to add a new product type, Product &#8211; Print, I need fields like colour and size that aren&#8217;t included in the Product &#8211; General type.<\/p>\n<p>For the All product listing and New product listing pages the product_type_layout file determines which fields appear on the screen.\u00a0 The simplest thing is to duplicate the existing product_type_layout entries for product_type = &#8216;1&#8217;\u00a0 (Product &#8211; General), the copy can then be used as a base for the display of the new product_type.<\/p>\n<p>So to save somebody some work I offer this mySQL statement which copies all the product_type_layout records for Product &#8211; General and creates a new version for Product &#8211; Print;<br \/>\n<pre class=\"preserve-code-formatting\">INSERT INTO product_type_layout \n&nbsp;&nbsp;(configuration_title,\n&nbsp;&nbsp; configuration_key,\n&nbsp;&nbsp; configuration_value, \n&nbsp;&nbsp; configuration_description,\n&nbsp;&nbsp; product_type_id,\n&nbsp;&nbsp; sort_order,\n&nbsp;&nbsp; last_modified,\n&nbsp;&nbsp; date_added,\n&nbsp;&nbsp; use_function,\n&nbsp;&nbsp; set_function)\nSELECT\n&nbsp;&nbsp; configuration_title, \n&nbsp;&nbsp; REPLACE(configuration_key,&#039;PRODUCT_&#039;,&#039;PRODUCT_PRINT_&#039;),&nbsp;&nbsp; \n&nbsp;&nbsp; configuration_value, \n&nbsp;&nbsp; configuration_description,\n&nbsp;&nbsp; &#039;6&#039;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp; sort_order,\n&nbsp;&nbsp; now(),\n&nbsp;&nbsp; now(),\n&nbsp;&nbsp; use_function,\n&nbsp;&nbsp; set_function \nFROM product_type_layout\n&nbsp;&nbsp;WHERE product_type_id = &#039;1&#039;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n<\/pre><br \/>\nThe new records are a copy of the existing Product &#8211; General records except;<\/p>\n<ul>\n<li>configuration_id isn&#8217;t explicitly set, this will be handled by mySQL&#8217;s auto_increment.<\/li>\n<li>The configuration_key text PRODUCT_ is replaced by PRODUCT_PRINT &#8211; we can&#8217;t have duplicate configuration_key values.<\/li>\n<li>The new product_type_id = &#8216;6&#8217; which is the value for my new Product &#8211; Print type.<\/li>\n<li>The last_modified and date_added fields are set to the current date\/time.<\/li>\n<\/ul>\n<p>I ran this enquiry using phpMyAdmin in my test environment but I used the Tools\/Install SQL Patches option in Zen Cart&#8217;s admin area to apply the same change to the live site.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>I have been working on a new site for Global Art Prints.\u00a0 The site is an online shop selling Limited Edition prints, mainly by British artists. \u00a0 I have customised a Zen Cart eCommerce installation to suit the new shop.\u00a0 As part of the process I have needed to add a new product type, Product [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20,101,90,18],"tags":[146,148,99],"_links":{"self":[{"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/posts\/155"}],"collection":[{"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/comments?post=155"}],"version-history":[{"count":11,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/posts\/155\/revisions"}],"predecessor-version":[{"id":194,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/posts\/155\/revisions\/194"}],"wp:attachment":[{"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/media?parent=155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/categories?post=155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/tags?post=155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}