Difference between revisions of "importing data into ZenCart"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
(→‎Patches: headers; filename field for custom_uploads)
m (→‎new tables: image -> file)
Line 60: Line 60:
 
   `filename` varchar(255) NOT NULL COMMENT 'name of archive (zipfile or tarball) being uploaded',
 
   `filename` varchar(255) NOT NULL COMMENT 'name of archive (zipfile or tarball) being uploaded',
 
   `comment` varchar(255) DEFAULT ''
 
   `comment` varchar(255) DEFAULT ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='custom table for managing bulk image uploads';
+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='custom table for managing bulk file uploads';
  
 
CREATE TABLE `custom_upload_files` (
 
CREATE TABLE `custom_upload_files` (

Revision as of 17:00, 12 March 2007

Navigation

computing: software: ZenCart: importing data

Overview

ZenCart, as of this writing, has no facility for importing business data for other applications. Due to ZenCart's open source nature, however, it is not difficult to write such a routine and add it to the menu of available functions in the Administration section. The necessary particulars are not very well documented yet, so this page will be a collection point for that information.

Patches

Note: I am currently in the process of adding a bulk-image-upload capability; the code presented here works for bulk data entry, but the image upload capability is incomplete. --Woozle 15:03, 10 March 2007 (EST)

custom_dhtml.php

  • new file: admin/includes/boxes/custom_dhtml.php

<php><?php /*

2006-09-17 (wzl) custom menu loader based on reports.dhtml and others
REQUIRES:

admin/custom_menu.php single-line modification to admin/includes/header_navigation.php

  • /

if (!defined('IS_ADMIN_FLAG')) {

 die('Illegal Access');

}

define('CUSTOM_MENU_MODULE', 'custom_menu');

 $za_contents = array();
 $za_heading = array();

// 2006-09-17 (Wzl) this could ultimately use language defines, but for now I am hard-coding the text

 $za_heading = array('text' => 'Jubilee Custom Functions', 'link' => zen_href_link(CUSTOM_MENU_MODULE, , 'NONSSL'));
 $za_contents[] = array('text' => 'Bulk product entry', 'link' => zen_href_link(CUSTOM_MENU_MODULE, 'set=prod_entry', 'NONSSL'));

?> <?php echo zen_draw_admin_box($za_heading, $za_contents); ?> </php> "Jubilee Custom Functions" can be replaced by whatever text seems appropriate; "Jubilee" was part of the name of the store I was setting up, and I wanted to make it clear to the owner that this was the menu entry I had written for him.

custom_menu.php

header_navigation.php

  • file edit: admin/includes/header_navigation.php

<php>// require(DIR_WS_BOXES . 'extras_dhtml.php');

 require(DIR_WS_BOXES . 'custom_dhtml.php');</php>

Removing extras_dhtml.php is optional; the store I was setting up had no use for it.

new tables

So far, I haven't needed to use the new table names in more than one file; if I do, I'll need to move the defines from admin/custom_menu.php to includes/database_tables.php

  • new tables:

<sql>CREATE TABLE `custom_import_mfgrs` (

 `id_mfgr` int(11) NOT NULL default '0' COMMENT 'manufacturers.id',
 `import_alias` varchar(255) NOT NULL default  COMMENT 'name used in import data'

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `custom_import_prod` (

 `import_key` varchar(255) default NULL,
 `prod_key` int(11) default NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='custom table for handling imported products';

CREATE TABLE `custom_uploads` (

 `id` int(11) NOT NULL key auto_increment,
 `id_admin` int(11) NOT NULL default '0' COMMENT 'who did the upload (admin.admin_id)',
 `when_started` datetime default NULL COMMENT 'timestamp of when the upload started',
 `when_finished` datetime default NULL COMMENT 'timestamp of when the upload finished; NULL means incomplete',
 `filename` varchar(255) NOT NULL COMMENT 'name of archive (zipfile or tarball) being uploaded',
 `comment` varchar(255) DEFAULT 

) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='custom table for managing bulk file uploads';

CREATE TABLE `custom_upload_files` (

 `id` int(11) NOT NULL key auto_increment,
 `id_upload` int(11) NOT NULL COMMENT 'custom_uploads.id',
 `filespec` varchar(255) NOT NULL COMMENT 'relative filespec of image file',
 `id_prod` int(11) default NULL COMMENT 'products.products_id - product to which this image was assigned'

) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='detail table for custom_uploads: one record per file';</sql>

Reference