Jump to content
Sign in to follow this  
astecme

Date entered on product copy is wrong.

Recommended Posts

Hi,

 

 Where I have products that are close to each other I have always used the copy as new product feature. I noticed tonight that Under Phoenix this copies the date entered across. I think it really ought to change it for the current time but...

Anyone else see this "problem"?

Also I tried to change the database to change the date enetered in the products table. The dtae changes but it seems to have no effect on the products when displayed. Anyone help with fixing this?

 

Thanks

 

Allan

Share this post


Link to post
Share on other sites

You must have a problem with your install or database as copy product works fine on stock install, as you can see just copied ORA-2 from ORA-1 and dates have changed.

 

image.thumb.png.da41e142dac215de97bcbc92de58cae7.png


 

Share this post


Link to post
Share on other sites

Also,  make sure when copying the products that you do not have the 'link products' option selected (unless you want to link products) as they will have the same date added.

Peter


PROUDLY PASSIONATE PHOENIX SUPPORTER

Full-time I am a C-suite executive of a large retail company in Australia. In my spare time, I enjoying learning about web-design.

Download the latest version of CE Phoenix from gitHub here

Join the Phoenix Club. Become a Phoenix Supporter.  Gain access to special codes and modules and help the project thrive. Read here

 

Share this post


Link to post
Share on other sites
On 10/11/2019 at 8:58 PM, JcMagpie said:

You must have a problem with your install or database as copy product works fine on stock install, as you can see just copied ORA-2 from ORA-1 and dates have changed.

 

image.thumb.png.da41e142dac215de97bcbc92de58cae7.png

 

Share this post


Link to post
Share on other sites

Thats possible as I have added some code so that I have a purchase price and also copy that across. I will check what I copied!

Share this post


Link to post
Share on other sites

here is my code, I cannot see what can be wrong...

          if ($_POST['copy_as'] == 'link') {
            if ($categories_id != $current_category_id) {
              $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$categories_id . "'");
              $check = tep_db_fetch_array($check_query);
              if ($check['total'] < '1') {
                tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$categories_id . "')");
              }
            } else {
              $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');
            }
          } elseif ($_POST['copy_as'] == 'duplicate') {
            $product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_cost, products_date_available, products_weight, products_tax_class_id, manufacturers_id, products_gtin from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
            $product = tep_db_fetch_array($product_query);

            tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_cost, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_gtin) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "' , '" . tep_db_input($product['products_cost']) . "',  now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "', '" . tep_db_input($product['products_gtin']) . "')");
            $dup_products_id = tep_db_insert_id();

            $description_query = tep_db_query("select language_id, products_name, products_description, products_url, products_seo_title, products_seo_description, products_seo_keywords from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
            while ($description = tep_db_fetch_array($description_query)) {
              tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed, products_seo_title, products_seo_description, products_seo_keywords) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0', '" . tep_db_input($description['products_seo_title']) . "', '" . tep_db_input($description['products_seo_description']) . "', '" . tep_db_input($description['products_seo_keywords']) . "')");
            }

            $product_images_query = tep_db_query("select image, htmlcontent, sort_order from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$products_id . "'");
            while ($product_images = tep_db_fetch_array($product_images_query)) {
              tep_db_query("insert into " . TABLE_PRODUCTS_IMAGES . " (products_id, image, htmlcontent, sort_order) values ('" . (int)$dup_products_id . "', '" . tep_db_input($product_images['image']) . "', '" . tep_db_input($product_images['htmlcontent']) . "', '" . tep_db_input($product_images['sort_order']) . "')");
            }

            tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");
            $products_id = $dup_products_id;
          }

 

Any help gratefully accepted!

 

Share this post


Link to post
Share on other sites
On 10/11/2019 at 3:24 PM, astecme said:

Also I tried to change the database to change the date enetered in the products table. The dtae changes but it seems to have no effect on the products when displayed.

Sorry, I guess we should have noticed this earlier.  I would try looking at the query that *reads* the date when the product is displayed.  Because if changing the database value doesn't fix it, that isn't an insert problem. 

The query that inserts the date seems to be correct. 

            tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_cost, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_gtin) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "' , '" . tep_db_input($product['products_cost']) . "',  now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "', '" . tep_db_input($product['products_gtin']) . "')");

You also may want to consider the difference between products_date_added and products_date_available.  It copies the date available but sets a new date added. 


Always back up before making changes.

Share this post


Link to post
Share on other sites

Ecartz, Thanks Thats what it is supposed to do. I have now added a line prior to the insert

 

$products_date_added = (date('Y-m-d'));

 

and changed the Now() to  "$products_date_added" that works as needed.

Many thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×