{"id":1482,"date":"2016-04-22T14:27:22","date_gmt":"2016-04-22T13:27:22","guid":{"rendered":"http:\/\/doc.atlantisevo.com\/?post_type=manual_documentation&#038;p=1482"},"modified":"2021-01-28T09:43:47","modified_gmt":"2021-01-28T08:43:47","slug":"operazioni-preliminari","status":"publish","type":"manual_documentation","link":"https:\/\/www.atlantisevo.com\/doc\/manuale\/e-commerce-terzi\/virtuemart2\/operazioni-preliminari\/","title":{"rendered":"Operazioni preliminari"},"content":{"rendered":"<div id=\"toctoc\"><\/div><h4>Creare le seguenti tabelle:<\/h4>\n<table class=\"table-code\">\n<tbody>\n<tr class=\"alt first last\">\n<td>##<br \/>\n## Product<br \/>\n##CREATE TABLE IF NOT EXISTS `sync_prod` (<br \/>\n`id` int(11) NOT NULL AUTO_INCREMENT,<br \/>\n`op` char(1) NOT NULL,<br \/>\n`product_id` int(11) NOT NULL,<br \/>\n`product_sku` varchar(64) NOT NULL,<br \/>\nPRIMARY KEY (`id`),<br \/>\nUNIQUE KEY `sync_prod_unique` (`op`,`product_id`,`product_sku`)<br \/>\n) ENGINE=MyISAM\u00a0 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table class=\"table-code\" style=\"height: 257px;\" width=\"536\">\n<tbody>\n<tr class=\"alt first last\">\n<td style=\"width: 526px;\">##<br \/>\n## order item<br \/>\n##CREATE TABLE IF NOT EXISTS `sync_orditem` (<br \/>\n`id` int(11) NOT NULL AUTO_INCREMENT,<br \/>\n`op` char(1) NOT NULL,<br \/>\n`order_id` int(11) NOT NULL,<br \/>\nPRIMARY KEY (`id`),<br \/>\nUNIQUE KEY `sync_orditem_unique` (`op`,`order_id`)<br \/>\n) ENGINE=MyISAM\u00a0 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table class=\"table-code\">\n<tbody>\n<tr class=\"alt first last\">\n<td>##<br \/>\n## User<br \/>\n##CREATE TABLE IF NOT EXISTS `sync_user` (<br \/>\n`id` int(11) NOT NULL AUTO_INCREMENT,<br \/>\n`op` char(1) NOT NULL,<br \/>\n`user_id` int(11) NOT NULL,<br \/>\nPRIMARY KEY (`id`),<br \/>\nUNIQUE KEY `sync_user_unique` (`op`,`user_id`)<br \/>\n) ENGINE=MyISAM\u00a0 DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Trigger da attivare su MySql per le tabelle appena create:<\/h4>\n<table class=\"table-code\" style=\"width: 1085px;\">\n<tbody>\n<tr class=\"alt first last\">\n<td style=\"width: 1077px;\">CREATE TRIGGER product_insert AFTER INSERT ON jos_vm_product<br \/>\nFOR EACH ROW<br \/>\nINSERT INTO sync_prod (op,product_id,product_sku) VALUES (&#8216;I&#8217;,NEW.product_id,NEW.product_sku);CREATE TRIGGER product_delete AFTER DELETE ON jos_vm_product<br \/>\nFOR EACH ROW<br \/>\nINSERT INTO sync_prod (op,product_id,product_sku) VALUES (&#8216;D&#8217;,OLD.product_id,OLD.product_sku);DELIMITER $$<br \/>\nCREATE TRIGGER product_update AFTER UPDATE ON jos_vm_product<br \/>\nFOR EACH ROW<br \/>\nBEGIN<br \/>\nIF NEW.product_in_stock=OLD.product_in_stock THEN<br \/>\nREPLACE INTO sync_prod (op,product_id,product_sku) VALUES (&#8216;U&#8217;,NEW.product_id,NEW.product_sku);<br \/>\nEND IF;<br \/>\nEND$$<br \/>\nDELIMITER ;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table class=\"table-code\" style=\"width: 1085px;\">\n<tbody>\n<tr class=\"alt first last\">\n<td style=\"width: 1079px;\">CREATE TRIGGER orderitem_insert AFTER INSERT ON jos_vm_order_item<br \/>\nFOR EACH ROW<br \/>\nINSERT INTO sync_orditem (op,order_id) VALUES (&#8216;I&#8217;,NEW.order_id);CREATE TRIGGER orderitem_delete AFTER DELETE ON jos_vm_order_item<br \/>\nFOR EACH ROW<br \/>\nINSERT INTO sync_orditem (op,order_id) VALUES (&#8216;D&#8217;,OLD.order_id);DELIMITER $$<br \/>\nCREATE TRIGGER orderitem_update AFTER UPDATE ON jos_vm_order_item<br \/>\nFOR EACH ROW<br \/>\nBEGIN<br \/>\nREPLACE INTO sync_orditem (op,order_id) VALUES (&#8216;U&#8217;,NEW.order_id);<br \/>\nEND$$<br \/>\nDELIMITER ;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table class=\"table-code\">\n<tbody>\n<tr class=\"alt first last\">\n<td>CREATE TRIGGER user_insert AFTER INSERT ON jos_vm_user_info<br \/>\nFOR EACH ROW<br \/>\nINSERT INTO sync_user (op,user_id) VALUES (&#8216;I&#8217;,NEW.user_id);CREATE TRIGGER user_delete AFTER DELETE ON jos_vm_user_info<br \/>\nFOR EACH ROW<br \/>\nINSERT INTO sync_user (op,user_id) VALUES (&#8216;D&#8217;,OLD.user_id);DELIMITER $$<br \/>\nCREATE TRIGGER user_update AFTER UPDATE ON jos_vm_user_info<br \/>\nFOR EACH ROW<br \/>\nBEGIN<br \/>\nREPLACE INTO sync_user (op,user_id) VALUES (&#8216;U&#8217;,NEW.user_id);<br \/>\nEND$$<br \/>\nDELIMITER ;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Esempio di sync_prod:<\/h4>\n<table id=\"table_results\" class=\"data\" style=\"width: 727px;\">\n<tbody>\n<tr>\n<th style=\"width: 129px; text-align: center;\">id<\/th>\n<th style=\"width: 140px; text-align: center;\">op<\/th>\n<th style=\"width: 256px; text-align: center;\">product_id<\/th>\n<th style=\"width: 206px; text-align: left;\">product_sku<\/th>\n<\/tr>\n<tr class=\"odd alt\">\n<td class=\"nowrap\" style=\"width: 129px; text-align: center;\" align=\"right\">1<\/td>\n<td class=\"\" style=\"width: 140px; text-align: center;\">D<\/td>\n<td class=\"nowrap\" style=\"width: 256px; text-align: center;\" align=\"right\">1<\/td>\n<td class=\"\" style=\"width: 206px;\">ZZZ<\/td>\n<\/tr>\n<tr class=\"even\">\n<td class=\"nowrap\" style=\"width: 129px; text-align: center;\" align=\"right\">2<\/td>\n<td class=\"\" style=\"width: 140px; text-align: center;\">I<\/td>\n<td class=\"nowrap\" style=\"width: 256px; text-align: center;\" align=\"right\">810<\/td>\n<td class=\"\" style=\"width: 206px;\">A011M<\/td>\n<\/tr>\n<tr class=\"odd alt last\">\n<td class=\"nowrap\" style=\"width: 129px; text-align: center;\" align=\"right\">3<\/td>\n<td class=\"\" style=\"width: 140px; text-align: center;\">I<\/td>\n<td class=\"nowrap\" style=\"width: 256px; text-align: center;\" align=\"right\">811<\/td>\n<td class=\"\" style=\"width: 206px;\">P22<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Esempio di sync_orditem:<\/h4>\n<table id=\"table_results\" class=\"data\" style=\"width: 522px;\">\n<tbody>\n<tr>\n<th style=\"width: 128px; text-align: center;\">id<\/th>\n<th style=\"width: 136px; text-align: center;\">op<\/th>\n<th style=\"width: 242px; text-align: center;\">order_id<\/th>\n<\/tr>\n<tr class=\"odd alt\">\n<td class=\"nowrap\" style=\"width: 128px; text-align: center;\" align=\"right\">1<\/td>\n<td class=\"\" style=\"width: 136px; text-align: center;\">I<\/td>\n<td class=\"nowrap\" style=\"width: 242px; text-align: center;\" align=\"right\">1<\/td>\n<\/tr>\n<tr class=\"even\">\n<td class=\"nowrap\" style=\"width: 128px; text-align: center;\" align=\"right\">2<\/td>\n<td class=\"\" style=\"width: 136px; text-align: center;\">U<\/td>\n<td class=\"nowrap\" style=\"width: 242px; text-align: center;\" align=\"right\">1<\/td>\n<\/tr>\n<tr class=\"odd alt last\">\n<td class=\"nowrap\" style=\"width: 128px; text-align: center;\" align=\"right\">3<\/td>\n<td class=\"\" style=\"width: 136px; text-align: center;\">D<\/td>\n<td class=\"nowrap\" style=\"width: 242px; text-align: center;\" align=\"right\">1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Query per riempire \u00a0tabelle prima installazione:<\/h4>\n<table class=\"table-code\">\n<tbody>\n<tr class=\"alt first last\">\n<td>INSERT INTO sync_user (op, user_id) SELECT &#8216;U&#8217;,ui.user_id FROM jos_vm_user_info ui,jos_users u,jos_vm_shopper_vendor_xref rf WHERE address_type =&#8217;BT&#8217; AND ui.user_id=u.id AND rf.user_id=u.id GROUP BY ui.user_id<br \/>\nINSERT INTO sync_prod (op,product_id,product_sku) SELECT distinct &#8216;U&#8217;,product_id,product_sku from jos_vm_productINSERT INTO\u00a0sync_orditem (op,order_id) SELECT distinct &#8216;U&#8217;,order_id from\u00a0jos_vm_order_item<br \/>\noppure<br \/>\nINSERT INTO\u00a0sync_orditem (op,order_id) SELECT DISTINCT &#8216;U&#8217;, order_id FROM jos_vm_orders WHERE left( FROM_UNIXTIME( cdate ) , 4 ) = &#8216;2012&#8217; ORDER BY order_id<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"author":1,"featured_media":0,"parent":1479,"menu_order":2,"template":"","manualdocumentationcategory":[55],"manual_doc_tag":[],"_links":{"self":[{"href":"https:\/\/www.atlantisevo.com\/doc\/wp-json\/wp\/v2\/manual_documentation\/1482"}],"collection":[{"href":"https:\/\/www.atlantisevo.com\/doc\/wp-json\/wp\/v2\/manual_documentation"}],"about":[{"href":"https:\/\/www.atlantisevo.com\/doc\/wp-json\/wp\/v2\/types\/manual_documentation"}],"author":[{"embeddable":true,"href":"https:\/\/www.atlantisevo.com\/doc\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":14,"href":"https:\/\/www.atlantisevo.com\/doc\/wp-json\/wp\/v2\/manual_documentation\/1482\/revisions"}],"predecessor-version":[{"id":1496,"href":"https:\/\/www.atlantisevo.com\/doc\/wp-json\/wp\/v2\/manual_documentation\/1482\/revisions\/1496"}],"up":[{"embeddable":true,"href":"https:\/\/www.atlantisevo.com\/doc\/wp-json\/wp\/v2\/manual_documentation\/1479"}],"wp:attachment":[{"href":"https:\/\/www.atlantisevo.com\/doc\/wp-json\/wp\/v2\/media?parent=1482"}],"wp:term":[{"taxonomy":"manualdocumentationcategory","embeddable":true,"href":"https:\/\/www.atlantisevo.com\/doc\/wp-json\/wp\/v2\/manualdocumentationcategory?post=1482"},{"taxonomy":"manual_doc_tag","embeddable":true,"href":"https:\/\/www.atlantisevo.com\/doc\/wp-json\/wp\/v2\/manual_doc_tag?post=1482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}