Hi Kevin!
Currently there is no way to EDIT your option values/names. You would need to do this via the admin. If you change the names and import then you'll end up with both sets of values.
-chadd
Printable View
Did you create a new product type? There is an entry for v_products_type, but music products are type = 2 (if memory serves). You can set the product type with the current version of EP4.
If you are talking about adding NEW tables, then there would be custom coding for EP to use these. Perhaps I don't fully understand what you are doing ....
-chadd
Yeah, sorry, i added a NEW product type, with extra tables (SIMILAR to music's record companies and genres, but with DVD Studios and dvd genres). which EP files would i have to mess with?
It should be very doable if you have a good grasp of PHP.
You will work mostly with admin/includes/functions/extra_functions/easypopulate_4_functions.php
If you look at that closely, it is here that you define your file formats and queries.
Then you'd have to edit both the easypopulate_4_import.php and easypopulate_4_export.php files. If your tables
are very similar to the music tables, you should be able to follow the code.
Hope that helps.
-chadd
awesome! thanks a lot, i'll check it out. though i'll probably be posting again if i end up ripping my hair out...
So, so far i have made it so that dvd type shows up in the configure options, and the proper fields export on to the spreadsheet. the ONLY thing i can't quite get to work is the import. I don't know how much you feel like combing through code, but this is what i have modified: (from record_companies and music_genre)
Code:// HERE ==========================>
// BEGIN: studios
if (isset($filelayout['v_studios_name']) ) {
if ( isset($v_studios_name) && ($v_studios_name != '') && (mb_strlen($v_studios_name) <= $studio_name_max_len) ) {
$sql = "SELECT studios_id AS studiosID FROM ".TABLE_STUDIOS." WHERE studios_name = '".addslashes(ep_4_curly_quotes($v_studios_name))."' LIMIT 1";
$result = ep_4_query($sql);
if ( $row = mysql_fetch_array($result) ) {
$v_studios_id = $row['studiosID']; // this id goes into the product_dvd_extra table
$sql = "UPDATE ".TABLE_STUDIOS." SET
studios_image = '".addslashes($v_studios_image)."',
last_modified = CURRENT_TIMESTAMP
WHERE studios_id = '".$v_studios_id."'";
$result = ep_4_query($sql);
foreach ($langcode as $lang) {
$l_id = $lang['id'];
$sql = "UPDATE ".TABLE_STUDIOS_INFO." SET
studios_url = '".addslashes($items[$filelayout['v_studios_url_'.$lid]])."'
WHERE studios_id = '".$v_studios_id."' AND languages_id = '".$lid."'";
$result = ep_4_query($sql);
}
} else { // It is set to autoincrement, do not need to fetch max id
$sql = "INSERT INTO ".TABLE_STUDIOS." (studios_name, studios_image, date_added, last_modified)
VALUES ('".addslashes(ep_4_curly_quotes($v_studios_name))."', '".addslashes($v_studios_image)."', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)";
$result = ep_4_query($sql);
$v_studios_id = mysql_insert_id(); // id is auto_increment, so can use this function
foreach ($langcode as $lang) {
$l_id = $lang['id'];
$sql = "INSERT INTO ".TABLE_STUDIOS_INFO." (studios_id, languages_id, studios_url)
VALUES ('".addslashes($v_studios_id)."',".(int)$l_id.",'".addslashes($items[$filelayout['v_studios_url_'.$lid]])."')"; // seems we are skipping manufacturers url
$result = ep_4_query($sql);
}
}
} else { // $v_studios_name == '' or name length violation
if (mb_strlen($v_studios_name) > $studio_name_max_len) {
$display_output .= sprintf(EASYPOPULATE_4_DISPLAY_RESULT_STUDIOS_NAME_LONG, $v_studios_name, $studio_name_max_len);
$ep_error_count++;
continue;
}
$v_studios_id = 0; // studios_id = '0' for no assigned artists
}
}
// END: studios
// HERE ==========================>
// BEGIN: dvd_genre
if (isset($filelayout['v_dvd_genre_name']) ) {
if ( isset($v_dvd_genre_name) && ($v_dvd_genre_name != '') && (mb_strlen($v_dvd_genre_name) <= $dvd_genre_name_max_len) ) {
$sql = "SELECT dvd_genre_id AS dvd_genreID FROM ".TABLE_DVD_GENRE." WHERE dvd_genre_name = '".addslashes($v_dvd_genre_name)."' LIMIT 1";
$result = ep_4_query($sql);
if ( $row = mysql_fetch_array($result) ) {
$v_dvd_genre_id = $row['dvd_genreID']; // this id goes into the product_dvd_extra table
} else { // It is set to autoincrement, do not need to fetch max id
$sql = "INSERT INTO ".TABLE_DVD_GENRE." (dvd_genre_name, date_added, last_modified)
VALUES ('".addslashes($v_dvd_genre_name)."', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)";
$result = ep_4_query($sql);
$v_dvd_genre_id = mysql_insert_id(); // id is auto_increment
}
} else { // $v_dvd_genre_name == '' or name length violation
if (mb_strlen($v_dvd_genre_name) > $dvd_genre_name_max_len) {
$display_output .= sprintf(EASYPOPULATE_4_DISPLAY_RESULT_DVD_GENRE_NAME_LONG, $v_dvd_genre_name, $dvd_genre_name_max_len);
$ep_error_count++;
continue;
}
$v_dvd_genre_id = 0; // chadd - zencart uses genre_id = '0' for no assigned artists
}
}
// END: dvd_genre
// insert new, or update existing, product
if ($v_products_model != "") { // products_model exists!
// First we check to see if this is a product in the current db.
$result = ep_4_query("SELECT products_id FROM ".TABLE_PRODUCTS." WHERE (products_model = '".addslashes($v_products_model)."') LIMIT 1");
if (mysql_num_rows($result) == 0) { // new item, insert into products
$v_date_added = ($v_date_added == 'NULL') ? CURRENT_TIMESTAMP : $v_date_added;
$sql = "SHOW TABLE STATUS LIKE '".TABLE_PRODUCTS."'";
$result = ep_4_query($sql);
$row = mysql_fetch_array($result);
$max_product_id = $row['Auto_increment'];
if (!is_numeric($max_product_id) ) {
$max_product_id = 1;
}
$v_products_id = $max_product_id;
if ($v_studios_name <> '') {
$v_products_type = 6; // 6 = dvd
} else {
$v_products_type = 1; // 1 = standard product
}
$query = "INSERT INTO ".TABLE_PRODUCTS." SET
products_model = '".addslashes($v_products_model)."',
products_type = '".(int)$v_products_type."',
products_price = '".$v_products_price."',";
if ($ep_supported_mods['uom'] == true) { // price UOM mod
$query .= "products_price_uom = '".$v_products_price_uom."',";
}
if ($ep_supported_mods['upc'] == true) { // UPC Code mod
$query .= "products_upc = '".addslashes($v_products_upc)."',";
}
if ($ep_supported_mods['gpc'] == true) { // Google Product Category for Google Merhcant Center - chadd 10-1-2011
$query .= "products_gpc = '".addslashes($v_products_gpc)."',";
}
if ($ep_supported_mods['msrp'] == true) { // Manufacturer's Suggested Retail Price
$query .= "products_msrp = '".$v_products_msrp."',";
}
if ($ep_supported_mods['gppi'] == true) { // Group Pricing Per Item
$query .= "products_group_a_price = '".$v_products_group_a_price."',";
$query .= "products_group_b_price = '".$v_products_group_b_price."',";
$query .= "products_group_c_price = '".$v_products_group_c_price."',";
$query .= "products_group_d_price = '".$v_products_group_d_price."',";
}
if ($ep_supported_mods['excl'] == true) { // Exclusive Product custom mod
$query .= "products_exclusive = '".addslashes($v_products_exclusive)."',";
}
if (count($custom_fields) > 0) {
foreach ($custom_fields as $field) {
$value ='v_'.$field;
$query .= "$field = '".addslashes($$value)."',";
}
}
$query .= "products_image = '".addslashes($v_products_image)."',
products_weight = '".$v_products_weight."',
products_discount_type = '".$v_products_discount_type."',
products_discount_type_from = '".$v_products_discount_type_from."',
product_is_call = '".$v_product_is_call."',
products_sort_order = '".$v_products_sort_order."',
products_quantity_order_min = '".$v_products_quantity_order_min."',
products_quantity_order_units = '".$v_products_quantity_order_units."',
products_priced_by_attribute = '".$v_products_priced_by_attribute."',
product_is_always_free_shipping = '".$v_product_is_always_free_shipping."',
products_tax_class_id = '".$v_tax_class_id."',
products_date_available = $v_date_avail,
products_date_added = $v_date_added,
products_last_modified = CURRENT_TIMESTAMP,
products_quantity = '".$v_products_quantity."',
master_categories_id = '".$v_categories_id."',
manufacturers_id = '".$v_manufacturers_id."',
products_status = '".$v_db_status."',
metatags_title_status = '".$v_metatags_title_status."',
metatags_products_name_status = '".$v_metatags_products_name_status."',
metatags_model_status = '".$v_metatags_model_status."',
metatags_price_status = '".$v_metatags_price_status."',
metatags_title_tagline_status = '".$v_metatags_title_tagline_status."'";
$result = ep_4_query($query);
if ($result == true) {
// need to change to an log file, this is gobbling up memory! chadd 11-14-2011
if ($ep_feedback == true) {
$display_output .= sprintf(EASYPOPULATE_4_DISPLAY_RESULT_NEW_PRODUCT, $v_products_model);
}
$ep_import_count++;
// PRODUCT_DVD_EXTRA
if ($v_products_type == '6') {
$sql_dvd_extra = ep_4_query("SELECT * FROM ".TABLE_PRODUCT_DVD_EXTRA." WHERE (products_id = '".$v_products_id."') LIMIT 1");
if (mysql_num_rows($sql_dvd_extra) == 0) { // new item, insert into products
$query = "INSERT INTO ".TABLE_PRODUCT_DVD_EXTRA." SET
products_id = '".$v_products_id."',
studios_id = '".$v_studios_id."',
dvd_genre_id = '".$v_dvd_genre_id."'";
$result = ep_4_query($query);
}
}
} else {
$display_output .= sprintf(EASYPOPULATE_4_DISPLAY_RESULT_NEW_PRODUCT_FAIL, $v_products_model);
$ep_error_count++;
continue; // new categories however have been created by now... Adding into product table needs to be 1st action?
}
// needs to go into log file chadd 11-14-2011
if ($ep_feedback == true) {
foreach ($items as $col => $summary) {
if ($col == $filelayout['v_products_model']) continue;
$display_output .= print_el_4($summary);
}
}
} else { // existing product, get the id from the query and update the product data
// if date added is null, let's keep the existing date in db..
$v_date_added = ($v_date_added == 'NULL') ? $row['v_date_added'] : $v_date_added; // if NULL, use date in db
$v_date_added = zen_not_null($v_date_added) ? $v_date_added : CURRENT_TIMESTAMP; // if updating, but date added is null, we use today's date
$row = mysql_fetch_array($result);
$v_products_id = $row['products_id'];
$row = mysql_fetch_array($result);
// CHADD - why is master_categories_id not being set on update???
$query = "UPDATE ".TABLE_PRODUCTS." SET
products_price = '".$v_products_price."',";
if ($ep_supported_mods['uom'] == true) { // price UOM mod
$query .= "products_price_uom = '".$v_products_price_uom."',";
}
if ($ep_supported_mods['upc'] == true) { // UPC Code mod
$query .= "products_upc = '".addslashes($v_products_upc)."',";
}
if ($ep_supported_mods['gpc'] == true) { // Google Product Category for Google Merhcant Center - chadd 10-1-2011
$query .= "products_gpc = '".addslashes($v_products_gpc)."',";
}
if ($ep_supported_mods['msrp'] == true) { // Manufacturer's Suggested Retail Price
$query .= "products_msrp = '".$v_products_msrp."',";
}
if ($ep_supported_mods['gppi'] == true) { // Group Pricing Per Item
$query .= "products_group_a_price = '".$v_products_group_a_price."',";
$query .= "products_group_b_price = '".$v_products_group_b_price."',";
$query .= "products_group_c_price = '".$v_products_group_c_price."',";
$query .= "products_group_d_price = '".$v_products_group_d_price."',";
}
if ($ep_supported_mods['excl'] == true) { // Exclusive Products custom mod
$query .= "products_exclusive = '".addslashes($v_products_exclusive)."',";
}
if (count($custom_fields) > 0) {
foreach ($custom_fields as $field) {
$value ='v_'.$field;
$query .= "$field = '".addslashes($$value)."',";
}
}
$query .= "products_image = '".addslashes($v_products_image)."',
products_weight = '".$v_products_weight."',
products_discount_type = '".$v_products_discount_type."',
products_discount_type_from = '".$v_products_discount_type_from."',
product_is_call = '".$v_product_is_call."',
products_sort_order = '".$v_products_sort_order."',
products_quantity_order_min = '".$v_products_quantity_order_min."',
products_quantity_order_units = '".$v_products_quantity_order_units."',
products_priced_by_attribute = '".$v_products_priced_by_attribute."',
product_is_always_free_shipping = '".$v_product_is_always_free_shipping."',
products_tax_class_id = '".$v_tax_class_id."',
products_date_available = $v_date_avail,
products_date_added = $v_date_added,
products_last_modified = CURRENT_TIMESTAMP,
products_quantity = '".$v_products_quantity."',
manufacturers_id = '".$v_manufacturers_id."',
products_status = '".$v_db_status."',
metatags_title_status = '".$v_metatags_title_status."',
metatags_products_name_status = '".$v_metatags_products_name_status."',
metatags_model_status = '".$v_metatags_model_status."',
metatags_price_status = '".$v_metatags_price_status."',
metatags_title_tagline_status = '".$v_metatags_title_tagline_status."'".
" WHERE (products_id = '".$v_products_id."')";
$result = ep_4_query($query);
if ($result == true) {
// needs to go into a log file chadd 11-14-2011
if ($ep_feedback == true) {
$display_output .= sprintf(EASYPOPULATE_4_DISPLAY_RESULT_UPDATE_PRODUCT, $v_products_model);
foreach ($items as $col => $summary) {
if ($col == $filelayout['v_products_model']) continue;
$display_output .= print_el_4($summary);
}
}
// PRODUCT_DVD_EXTRA
if ($v_products_type == '6') {
$sql_dvd_extra = ep_4_query("SELECT * FROM ".TABLE_PRODUCT_DVD_EXTRA." WHERE (products_id = '".$v_products_id."') LIMIT 1");
if (mysql_num_rows($sql_dvd_extra) == 1) { // update
$query = "UPDATE ".TABLE_PRODUCT_DVD_EXTRA." SET
studios_id = '".$v_studios_id."',
dvd_genre_id = '".$v_dvd_genre_id."'
WHERE products_id = '".$v_products_id."'";
$result = ep_4_query($query);
}
}
$ep_update_count++;
} else {
$display_output .= sprintf(EASYPOPULATE_4_DISPLAY_RESULT_UPDATE_PRODUCT_FAIL, $v_products_model);
$ep_error_count++;
}
}
WAIT WAIT ! i figured it out, i didn't need to copy most of that over again a second time. i got it totally working! awesomesauce. thanks man!
Bit quiet around here folks! Anyone got any suggestions for this?
I've checked the csv files on the (Linux) server and their owner group setting is:as opposed toCode:apache:apache
for the rest of the site files. I changed one of the CSVs toCode:myowner:psacln
but trying to downloading this file resulted in the same error.Code:myowner:psacln
Anybody?...
Try right-clicking the link and selecting "save target/link as". You may also try to change the permissions on your temp folder.
This can really depend on how php is run on your server (DSO, suPHP, FCGI, etc.) ... perhaps someone else has a better answer. IF all else fails, you should be able to pull them down with FTP even though that's really inconvenient.
-chadd