close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

eCart Store Summary not working how expected

Thread began 10/23/2016 11:49 am by Christopher West | Last modified 11/28/2016 11:15 am by Ray Borduin | 2181 views | 5 replies |

Christopher WestCommunity Expert

eCart Store Summary not working how expected

Hi, as the question topic suggests, I am having problems.

I'm using the server behavior to import data from a CSV file. I decided to use this method so that the client can edit product details and add new ones then import the file into the database. I feel that somewhere my logic is wrong. It works with adding new product entries, but doesn't update any existing products that have been edited in the csv file.

if you were to look at the core code below, is there an obvious reason or where I have gone wrong? (NOTE: I removed some of the columns to keep the code small for this topic (but it doesnt alter the functionality).

NOTE: ProductSKU is the only field that will never change and is unique, hence why I used it as a filter.

php:
<?php

if (($handle fopen("../files/libra-products.csv""r")) !== FALSE) {
   
fgetcsv($handle);   
   while ((
$data fgetcsv($handle1000",")) !== FALSE) {
        
$num count($data);
        for (
$c=0$c $num$c++) {
          
$col[$c] = $data[$c];
        }

 
$col1 $col[0];
 
$col2 $col[1];
 
$col3 $col[2];
 
$col4 $col[3];
 
$col5 $col[4];
 
$col6 $col[5];
 
$col7 $col[6];

 if (
"" == "") {
  
$ConditionalQuery = new WA_MySQLi_Query($ecartdb);
  
$ConditionalQuery->Action "conditional";
  
$ConditionalQuery->Table "products";
  
$ConditionalQuery->saveInSession("ProductSKU");
  
$ConditionalGoTo "";
  if (
function_exists("rel2abs")) $ConditionalGoTo $ConditionalGoTo?rel2abs($ConditionalGoTo,dirname(__FILE__)):"";
  
$ConditionalQuery->redirect($ConditionalGoTo);
  if (isset(
$_SESSION[$ConditionalQuery->SaveAs])) $ConditionalQuery->addFilter("ProductSKU""=""s"$_SESSION[$ConditionalQuery->SaveAs]);
  
$ConditionalQuery->bindColumn("ProductEnabled""s"$col1"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductSKU""s"$col2"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductName""s"$col3"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductBrand""s"$col4"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductPrice""s"$col5"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductRRP""s"$col6"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductQuantity""s"$col7"WA_DEFAULT");
  
$ConditionalQuery->execute();
}
   
 }
}
?>



Chris

Sign in to reply to this post

Ray BorduinWebAssist

It seems like this line:
if (isset($_SESSION[$ConditionalQuery->SaveAs])) $ConditionalQuery->addFilter("ProductSKU", "=", "s", $_SESSION[$ConditionalQuery->SaveAs]);

should be referring to the sku from your csv and not a session variable.

Sign in to reply to this post
Did this help? Tips are appreciated...

Christopher WestCommunity Expert

ah ok, can you give an example of how I should change that line please?

Chris

Sign in to reply to this post

Ray BorduinWebAssist

$ConditionalQuery->addFilter("ProductSKU", "=", "s", $col2);

Sign in to reply to this post
Did this help? Tips are appreciated...

Christopher WestCommunity Expert

Hi. it seems to work (database is update after initial tests) but i do get lots of these errors:

Notice: Undefined offset: 28 in C:\xampp\htdocs\armadillo\admin\libra-product-import.php on line 65

Notice: Undefined offset: 29 in C:\xampp\htdocs\armadillo\admin\libra-product-import.php on line 66

my current code is this:

php:
<?php

if (($handle fopen("../files/libra-products.csv""r")) !== FALSE) {
   
fgetcsv($handle);   
   while ((
$data fgetcsv($handle1000",")) !== FALSE) {
        
$num count($data);
        for (
$c=0$c $num$c++) {
          
$col[$c] = $data[$c];
        }

 
$col1 $col[0];
 
$col2 $col[1];
 
$col3 $col[2];
 
$col4 $col[3];
 
$col5 $col[4];
 
$col6 $col[5];
 
$col7 $col[6];
 
$col8 $col[7];
 
$col9 $col[8];
 
$col10 $col[9];
 
$col11 $col[10];
 
$col12 $col[11];
 
$col13 $col[12];
 
$col14 $col[13];
 
$col15 $col[14];
 
$col16 $col[15];
 
$col17 $col[16];
 
$col18 $col[17];
 
$col19 $col[18];
 
$col20 $col[19];
 
$col21 $col[20];
 
$col22 $col[21];
 
$col23 $col[22];
 
$col24 $col[23];
 
$col25 $col[24];
 
$col26 $col[25];
 
$col27 $col[26];
 
$col28 $col[27];
 
$col29 $col[28];
 
$col30 $col[29];
 if (
"" == "") {
  
$ConditionalQuery = new WA_MySQLi_Query($ecartdb);
  
$ConditionalQuery->Action "conditional";
  
$ConditionalQuery->Table "products";
  
$ConditionalQuery->saveInSession("ProductSKU");
  
$ConditionalGoTo "";
  if (
function_exists("rel2abs")) $ConditionalGoTo $ConditionalGoTo?rel2abs($ConditionalGoTo,dirname(__FILE__)):"";
  
$ConditionalQuery->redirect($ConditionalGoTo);
  if (
$ConditionalQuery->addFilter("ProductSKU""=""s"$col2));
  
$ConditionalQuery->bindColumn("ProductEnabled""s"$col1"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductSKU""s"$col2"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductName""s"$col3"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductBrand""s"$col4"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductPrice""s"$col5"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductRRP""s"$col6"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductQuantity""s"$col7"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductChargeDelivery""s"$col8"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductCollectionOnly""s"$col9"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductCallDelivery""s"$col10"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductSale""s"$col11"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductNewArrival""s"$col12"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductBestSeller""s"$col13"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductInStoreNow""s"$col14"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductWeight""s"$col15"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductHeight""s"$col16"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductWidth""s"$col17"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductDepth""s"$col18"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductDeliveryWeight""s"$col19"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductDeliveryHeight""s"$col20"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductDeliveryWidth""s"$col21"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductDeliveryDepth""s"$col22"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductDescription""s"$col23"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductKeywords""s"$col24"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductMetaTitle""s"$col25"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductMetaDescription""s"$col26"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductDiscontinued""s"$col27"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductOutStock""s"$col28"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductCreateDate""s"$col29"WA_DEFAULT");
  
$ConditionalQuery->bindColumn("ProductDateEdit""s"$col30"WA_DEFAULT");
  
$ConditionalQuery->execute();
}
   
 }
}
?>
Sign in to reply to this post

Ray BorduinWebAssist

This implies that there aren't 30 columns in the imported csv file, so it is complaining that you are referring to two columns that don't exist.

Sign in to reply to this post
Did this help? Tips are appreciated...

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...