From 414d98db27f6f28c5ef64f247d1c2d089aaa4cc3 Mon Sep 17 00:00:00 2001 From: gburton Date: Sun, 20 Nov 2016 17:21:22 +0000 Subject: [PATCH 1/2] GTIN Admin Side Update Shop Side Module Update DB Schema Update SQL Installer --- catalog/admin/categories.php | 16 ++++-- .../includes/languages/english/categories.txt | 1 + catalog/includes/OSC/Schema/products.txt | 1 + .../content/product_info/cm_pi_gtin.php | 13 ++++- catalog/install/oscommerce.sql | 56 +++++++++---------- 5 files changed, 52 insertions(+), 35 deletions(-) diff --git a/catalog/admin/categories.php b/catalog/admin/categories.php index b0bb14907..9f66ba8f6 100644 --- a/catalog/admin/categories.php +++ b/catalog/admin/categories.php @@ -243,6 +243,7 @@ 'products_status' => HTML::sanitize($_POST['products_status']), 'products_tax_class_id' => HTML::sanitize($_POST['products_tax_class_id']), 'manufacturers_id' => (int)HTML::sanitize($_POST['manufacturers_id'])); + $sql_data_array['products_gtin'] = (tep_not_null($_POST['products_gtin'])) ? str_pad(HTML::sanitize($_POST['products_gtin']), 14, '0', STR_PAD_LEFT) : 'null'; $products_image = new upload('products_image'); $products_image->set_destination(OSCOM::getConfig('dir_root', 'Shop') . 'images/'); @@ -397,7 +398,8 @@ 'products_weight' => $Qproduct->value('products_weight'), 'products_status' => 0, 'products_tax_class_id' => $Qproduct->valueInt('products_tax_class_id'), - 'manufacturers_id' => $Qproduct->valueInt('manufacturers_id') + 'manufacturers_id' => $Qproduct->valueInt('manufacturers_id'), + 'products_gtin' => $Qproduct->value('products_gtin'), ]); $dup_products_id = $OSCOM_Db->lastInsertId(); @@ -516,12 +518,13 @@ 'products_date_available' => '', 'products_status' => '', 'products_tax_class_id' => '', - 'manufacturers_id' => ''); + 'manufacturers_id' => '', + 'products_gtin' => ''); $pInfo = new objectInfo($parameters); if (isset($_GET['pID']) && empty($_POST)) { - $Qproduct = $OSCOM_Db->prepare('select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, "%Y-%m-%d") as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from :table_products p, :table_products_description pd where p.products_id = :products_id and p.products_id = pd.products_id and pd.language_id = :language_id'); + $Qproduct = $OSCOM_Db->prepare('select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, "%Y-%m-%d") as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_gtin from :table_products p, :table_products_description pd where p.products_id = :products_id and p.products_id = pd.products_id and pd.language_id = :language_id'); $Qproduct->bindInt(':products_id', $_GET['pID']); $Qproduct->bindInt(':language_id', $OSCOM_Language->getId()); $Qproduct->execute(); @@ -740,6 +743,10 @@ function updateNet() {
products_weight); ?>
+ +
+ products_gtin); ?> +
@@ -919,7 +926,8 @@ function updateNet() { 'p.products_last_modified', 'p.products_date_available', 'p.products_status', - 'p.manufacturers_id' + 'p.manufacturers_id', + 'p.products_gtin' ], [ 'p.products_id' => [ 'val' => (int)$_GET['pID'], diff --git a/catalog/admin/includes/languages/english/categories.txt b/catalog/admin/includes/languages/english/categories.txt index e8533fa8b..13465f151 100644 --- a/catalog/admin/includes/languages/english/categories.txt +++ b/catalog/admin/includes/languages/english/categories.txt @@ -69,6 +69,7 @@ text_products_url_without_http = (without http://) text_products_price_net = Products Price (Net): text_products_price_gross = Products Price (Gross): text_products_weight = Products Weight: +text_products_gtin = Products GTIN:
1 of UPC, EAN, ISBN etc empty_category = Empty Category text_how_to_copy = Copy Method: text_copy_as_link = Link product diff --git a/catalog/includes/OSC/Schema/products.txt b/catalog/includes/OSC/Schema/products.txt index 0aa21a570..bdf0ec93c 100644 --- a/catalog/includes/OSC/Schema/products.txt +++ b/catalog/includes/OSC/Schema/products.txt @@ -11,6 +11,7 @@ products_status tinyint(1) not_null products_tax_class_id int not_null manufacturers_id int products_ordered int default(0) not_null +products_gtin char(14) null -- primary products_id idx_products_model products_model diff --git a/catalog/includes/modules/content/product_info/cm_pi_gtin.php b/catalog/includes/modules/content/product_info/cm_pi_gtin.php index aa9ecaa92..127989c63 100644 --- a/catalog/includes/modules/content/product_info/cm_pi_gtin.php +++ b/catalog/includes/modules/content/product_info/cm_pi_gtin.php @@ -32,12 +32,19 @@ function __construct() { } function execute() { - global $oscTemplate, $product_info; + global $oscTemplate; $content_width = (int)MODULE_CONTENT_PRODUCT_INFO_GTIN_CONTENT_WIDTH; + + $OSCOM_Db = Registry::get('Db'); + + $Qgtin = $OSCOM_Db->prepare('select products_gtin from :table_products where products_id = :products_id'); + $Qgtin->bindInt(':products_id', $_GET['products_id']); + $Qgtin->execute(); - if (tep_not_null($product_info['products_gtin'])) { - $gtin = substr($product_info['products_gtin'], 0-MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH); + if ($Qgtin->fetch() !== false) { + $gtin = $Qgtin->valueProtected('products_gtin') + $gtin = substr($gtin, 0-MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH); ob_start(); include('includes/modules/content/' . $this->group . '/templates/gtin.php'); diff --git a/catalog/install/oscommerce.sql b/catalog/install/oscommerce.sql index faaa54f87..78485168c 100644 --- a/catalog/install/oscommerce.sql +++ b/catalog/install/oscommerce.sql @@ -489,34 +489,34 @@ INSERT INTO orders_status VALUES ( '1', '1', 'Pending', '1', '0'); INSERT INTO orders_status VALUES ( '2', '1', 'Processing', '1', '1'); INSERT INTO orders_status VALUES ( '3', '1', 'Delivered', '1', '1'); -INSERT INTO products VALUES (1,32,'MG200MMS','matrox/mg200mms.gif',299.99, now(),null,null,23.00,1,1,1,0); -INSERT INTO products VALUES (2,32,'MG400-32MB','matrox/mg400-32mb.gif',499.99, now(),null,null,23.00,1,1,1,0); -INSERT INTO products VALUES (3,2,'MSIMPRO','microsoft/msimpro.gif',49.99, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (4,13,'DVD-RPMK','dvd/replacement_killers.gif',42.00, now(),null,null,23.00,1,1,2,0); -INSERT INTO products VALUES (5,17,'DVD-BLDRNDC','dvd/blade_runner.gif',35.99, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (6,10,'DVD-MATR','dvd/the_matrix.gif',39.99, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (7,10,'DVD-YGEM','dvd/youve_got_mail.gif',34.99, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (8,10,'DVD-ABUG','dvd/a_bugs_life.gif',35.99, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (9,10,'DVD-UNSG','dvd/under_siege.gif',29.99, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (10,10,'DVD-UNSG2','dvd/under_siege2.gif',29.99, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (11,10,'DVD-FDBL','dvd/fire_down_below.gif',29.99, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (12,10,'DVD-DHWV','dvd/die_hard_3.gif',39.99, now(),null,null,7.00,1,1,4,0); -INSERT INTO products VALUES (13,10,'DVD-LTWP','dvd/lethal_weapon.gif',34.99, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (14,10,'DVD-REDC','dvd/red_corner.gif',32.00, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (15,10,'DVD-FRAN','dvd/frantic.gif',35.00, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (16,10,'DVD-CUFI','dvd/courage_under_fire.gif',38.99, now(),null,null,7.00,1,1,4,0); -INSERT INTO products VALUES (17,10,'DVD-SPEED','dvd/speed.gif',39.99, now(),null,null,7.00,1,1,4,0); -INSERT INTO products VALUES (18,10,'DVD-SPEED2','dvd/speed_2.gif',42.00, now(),null,null,7.00,1,1,4,0); -INSERT INTO products VALUES (19,10,'DVD-TSAB','dvd/theres_something_about_mary.gif',49.99, now(),null,null,7.00,1,1,4,0); -INSERT INTO products VALUES (20,10,'DVD-BELOVED','dvd/beloved.gif',54.99, now(),null,null,7.00,1,1,3,0); -INSERT INTO products VALUES (21,16,'PC-SWAT3','sierra/swat_3.gif',79.99, now(),null,null,7.00,1,1,7,0); -INSERT INTO products VALUES (22,13,'PC-UNTM','gt_interactive/unreal_tournament.gif',89.99, now(),null,null,7.00,1,1,8,0); -INSERT INTO products VALUES (23,16,'PC-TWOF','gt_interactive/wheel_of_time.gif',99.99, now(),null,null,10.00,1,1,8,0); -INSERT INTO products VALUES (24,17,'PC-DISC','gt_interactive/disciples.gif',90.00, now(),null,null,8.00,1,1,8,0); -INSERT INTO products VALUES (25,16,'MSINTKB','microsoft/intkeyboardps2.gif',69.99, now(),null,null,8.00,1,1,2,0); -INSERT INTO products VALUES (26,10,'MSIMEXP','microsoft/imexplorer.gif',64.95, now(),null,null,8.00,1,1,2,0); -INSERT INTO products VALUES (27,8,'HPLJ1100XI','hewlett_packard/lj1100xi.gif',499.99, now(),null,null,45.00,1,1,9,0); -INSERT INTO products VALUES (28,100,'GT-P1000','samsung/galaxy_tab.gif',749.99, now(),null,null,1,1,1,10,0); +INSERT INTO products VALUES (1,32,'MG200MMS','matrox/mg200mms.gif',299.99, now(),null,null,23.00,1,1,1,0,null); +INSERT INTO products VALUES (2,32,'MG400-32MB','matrox/mg400-32mb.gif',499.99, now(),null,null,23.00,1,1,1,0,null); +INSERT INTO products VALUES (3,2,'MSIMPRO','microsoft/msimpro.gif',49.99, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (4,13,'DVD-RPMK','dvd/replacement_killers.gif',42.00, now(),null,null,23.00,1,1,2,0,null); +INSERT INTO products VALUES (5,17,'DVD-BLDRNDC','dvd/blade_runner.gif',35.99, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (6,10,'DVD-MATR','dvd/the_matrix.gif',39.99, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (7,10,'DVD-YGEM','dvd/youve_got_mail.gif',34.99, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (8,10,'DVD-ABUG','dvd/a_bugs_life.gif',35.99, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (9,10,'DVD-UNSG','dvd/under_siege.gif',29.99, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (10,10,'DVD-UNSG2','dvd/under_siege2.gif',29.99, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (11,10,'DVD-FDBL','dvd/fire_down_below.gif',29.99, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (12,10,'DVD-DHWV','dvd/die_hard_3.gif',39.99, now(),null,null,7.00,1,1,4,0,null); +INSERT INTO products VALUES (13,10,'DVD-LTWP','dvd/lethal_weapon.gif',34.99, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (14,10,'DVD-REDC','dvd/red_corner.gif',32.00, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (15,10,'DVD-FRAN','dvd/frantic.gif',35.00, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (16,10,'DVD-CUFI','dvd/courage_under_fire.gif',38.99, now(),null,null,7.00,1,1,4,0,null); +INSERT INTO products VALUES (17,10,'DVD-SPEED','dvd/speed.gif',39.99, now(),null,null,7.00,1,1,4,0,null); +INSERT INTO products VALUES (18,10,'DVD-SPEED2','dvd/speed_2.gif',42.00, now(),null,null,7.00,1,1,4,0,null); +INSERT INTO products VALUES (19,10,'DVD-TSAB','dvd/theres_something_about_mary.gif',49.99, now(),null,null,7.00,1,1,4,0,null); +INSERT INTO products VALUES (20,10,'DVD-BELOVED','dvd/beloved.gif',54.99, now(),null,null,7.00,1,1,3,0,null); +INSERT INTO products VALUES (21,16,'PC-SWAT3','sierra/swat_3.gif',79.99, now(),null,null,7.00,1,1,7,0,null); +INSERT INTO products VALUES (22,13,'PC-UNTM','gt_interactive/unreal_tournament.gif',89.99, now(),null,null,7.00,1,1,8,0,null); +INSERT INTO products VALUES (23,16,'PC-TWOF','gt_interactive/wheel_of_time.gif',99.99, now(),null,null,10.00,1,1,8,0,null); +INSERT INTO products VALUES (24,17,'PC-DISC','gt_interactive/disciples.gif',90.00, now(),null,null,8.00,1,1,8,0,null); +INSERT INTO products VALUES (25,16,'MSINTKB','microsoft/intkeyboardps2.gif',69.99, now(),null,null,8.00,1,1,2,0,null); +INSERT INTO products VALUES (26,10,'MSIMEXP','microsoft/imexplorer.gif',64.95, now(),null,null,8.00,1,1,2,0,null); +INSERT INTO products VALUES (27,8,'HPLJ1100XI','hewlett_packard/lj1100xi.gif',499.99, now(),null,null,45.00,1,1,9,0,null); +INSERT INTO products VALUES (28,100,'GT-P1000','samsung/galaxy_tab.gif',749.99, now(),null,null,1,1,1,10,0,null); INSERT INTO products_description VALUES (1,1,'Matrox G200 MMS','Reinforcing its position as a multi-monitor trailblazer, Matrox Graphics Inc. has once again developed the most flexible and highly advanced solution in the industry. Introducing the new Matrox G200 Multi-Monitor Series; the first graphics card ever to support up to four DVI digital flat panel displays on a single 8" PCI board.

With continuing demand for digital flat panels in the financial workplace, the Matrox G200 MMS is the ultimate in flexible solutions. The Matrox G200 MMS also supports the new digital video interface (DVI) created by the Digital Display Working Group (DDWG) designed to ease the adoption of digital flat panels. Other configurations include composite video capture ability and onboard TV tuner, making the Matrox G200 MMS the complete solution for business needs.

Based on the award-winning MGA-G200 graphics chip, the Matrox G200 Multi-Monitor Series provides superior 2D/3D graphics acceleration to meet the demanding needs of business applications such as real-time stock quotes (Versus), live video feeds (Reuters & Bloombergs), multiple windows applications, word processing, spreadsheets and CAD.','www.matrox.com/mga/products/g200_mms/home.cfm',0, null, null, null); INSERT INTO products_description VALUES (2,1,'Matrox G400 32MB','Dramatically Different High Performance Graphics

Introducing the Millennium G400 Series - a dramatically different, high performance graphics experience. Armed with the industry\'s fastest graphics chip, the Millennium G400 Series takes explosive acceleration two steps further by adding unprecedented image quality, along with the most versatile display options for all your 3D, 2D and DVD applications. As the most powerful and innovative tools in your PC\'s arsenal, the Millennium G400 Series will not only change the way you see graphics, but will revolutionize the way you use your computer.

Key features:','www.matrox.com/mga/products/mill_g400/home.htm',0, null, null, null); From 09067b6d004aadd42ef061851567579436019431 Mon Sep 17 00:00:00 2001 From: Harald Ponce de Leon Date: Mon, 21 Nov 2016 03:04:16 +0100 Subject: [PATCH 2/2] general updates; language definition update --- catalog/admin/categories.php | 6 ++--- catalog/includes/OSC/Schema/products.txt | 2 +- .../content/product_info/cm_pi_gtin.php | 22 +++++++++++++------ .../content/product_info/templates/gtin.php | 6 ++++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/catalog/admin/categories.php b/catalog/admin/categories.php index 9f66ba8f6..7cb1eb350 100644 --- a/catalog/admin/categories.php +++ b/catalog/admin/categories.php @@ -242,8 +242,8 @@ 'products_weight' => (float)HTML::sanitize($_POST['products_weight']), 'products_status' => HTML::sanitize($_POST['products_status']), 'products_tax_class_id' => HTML::sanitize($_POST['products_tax_class_id']), - 'manufacturers_id' => (int)HTML::sanitize($_POST['manufacturers_id'])); - $sql_data_array['products_gtin'] = (tep_not_null($_POST['products_gtin'])) ? str_pad(HTML::sanitize($_POST['products_gtin']), 14, '0', STR_PAD_LEFT) : 'null'; + 'manufacturers_id' => (int)HTML::sanitize($_POST['manufacturers_id']), + 'products_gtin' => tep_not_null($_POST['products_gtin']) ? str_pad(HTML::sanitize($_POST['products_gtin']), 14, '0', STR_PAD_LEFT) : 'null'); $products_image = new upload('products_image'); $products_image->set_destination(OSCOM::getConfig('dir_root', 'Shop') . 'images/'); @@ -743,7 +743,7 @@ function updateNet() {
products_weight); ?>
- +
products_gtin); ?>
diff --git a/catalog/includes/OSC/Schema/products.txt b/catalog/includes/OSC/Schema/products.txt index bdf0ec93c..a7aa0ff61 100644 --- a/catalog/includes/OSC/Schema/products.txt +++ b/catalog/includes/OSC/Schema/products.txt @@ -11,7 +11,7 @@ products_status tinyint(1) not_null products_tax_class_id int not_null manufacturers_id int products_ordered int default(0) not_null -products_gtin char(14) null +products_gtin char(14) -- primary products_id idx_products_model products_model diff --git a/catalog/includes/modules/content/product_info/cm_pi_gtin.php b/catalog/includes/modules/content/product_info/cm_pi_gtin.php index 127989c63..ff573325d 100644 --- a/catalog/includes/modules/content/product_info/cm_pi_gtin.php +++ b/catalog/includes/modules/content/product_info/cm_pi_gtin.php @@ -6,6 +6,7 @@ * @license MIT; https://www.oscommerce.com/license/mit.txt */ + use OSC\OM\HTML; use OSC\OM\OSCOM; use OSC\OM\Registry; @@ -35,7 +36,7 @@ function execute() { global $oscTemplate; $content_width = (int)MODULE_CONTENT_PRODUCT_INFO_GTIN_CONTENT_WIDTH; - + $OSCOM_Db = Registry::get('Db'); $Qgtin = $OSCOM_Db->prepare('select products_gtin from :table_products where products_id = :products_id'); @@ -43,14 +44,21 @@ function execute() { $Qgtin->execute(); if ($Qgtin->fetch() !== false) { - $gtin = $Qgtin->valueProtected('products_gtin') - $gtin = substr($gtin, 0-MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH); + $gtin = $Qgtin->value('products_gtin'); + + if (!empty($gtin)) { + $gtin = substr($gtin, 0 - MODULE_CONTENT_PRODUCT_INFO_GTIN_LENGTH); + + if (!empty($gtin)) { + $gtin = HTML::outputProtected($gtin); - ob_start(); - include('includes/modules/content/' . $this->group . '/templates/gtin.php'); - $template = ob_get_clean(); + ob_start(); + include('includes/modules/content/' . $this->group . '/templates/gtin.php'); + $template = ob_get_clean(); - $oscTemplate->addContent($template, $this->group); + $oscTemplate->addContent($template, $this->group); + } + } } } diff --git a/catalog/includes/modules/content/product_info/templates/gtin.php b/catalog/includes/modules/content/product_info/templates/gtin.php index 10c77b7cf..b143717f5 100644 --- a/catalog/includes/modules/content/product_info/templates/gtin.php +++ b/catalog/includes/modules/content/product_info/templates/gtin.php @@ -1,8 +1,12 @@ + +
  • - +