X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   How to bulk change the price of ALL product (https://forum.x-cart.com/showthread.php?t=68664)

en4less 02-14-2014 11:01 AM

How to bulk change the price of ALL product
 
anybody has any idea how to do this, please share.
Let's say the price of all my products increased $5. How do we add $5 to the price of all products? Of course we don't want to go to 1000's of products and edit one at a time.

I think we have to go to the php codes and modify the price variable, but not where what file.

Any inputs will be appreciated very much. Thank you.

cflsystems 02-14-2014 05:02 PM

Re: How to bulk change the price of ALL product
 
This is how - http://www.cflsystems.com/products-bulk-pricing-for-x-cart.html

rogue 02-16-2014 05:56 AM

Re: How to bulk change the price of ALL product
 
You can do this by:
- Export your products
- Import into Excel
- Delete all columns except for productcode and price
- Rename price column to old_price
- Add a new column new_price with formula to adjust old price as desired.
- Copy values of of new_price to another new column called price.
- Delete the old_price and new_price column leaving only productcode and price
- Export to CSV
- Import to store

RichieRich 03-10-2014 12:02 PM

Re: How to bulk change the price of ALL product
 
this can be achieved with one line in the SQL i believe

cflsystems 03-10-2014 02:18 PM

Re: How to bulk change the price of ALL product
 
Quote:

Originally Posted by RichieRich
this can be achieved with one line in the SQL i believe


No you cannot. You can change the price in pricing table with simply sql statement but XC uses quick tables to cache and for faster access to pricing, also there is different pricing depending variants, options, membership, etc. so the one line sql statement may not be enough

TA 11-19-2015 08:54 AM

Re: How to bulk change the price of ALL product
 
Or you could just do this. https://www.cflsystems.com/products-bulk-prices-for-x-cart-classic.html
:wink:

voodoo1967 02-03-2020 02:09 PM

Re: How to bulk change the price of ALL product
 
Quote:

Originally Posted by TA


Is the mod 4.7.11 ready ?

Just ran the install - sql patches success, files uploaded ok, and file changes ok - cleared cache. Created a dummy directory and product. Applied bulk discount - increased by $1

and got this in the admin dashboard :-

* @copyright Copyright (c) 2015 CFL Systems, Inc. All rights reserved. * @license CFL Systems Software License Agreement - https://www.cflsystems.com/software-license-agreement.html * @link https://www.cflsystems.com/products-bulk-prices-for-x-cart-classic.html */if ( !defined('XCART_START') ) { header("Location: ../../"); die("Access denied"); }function csi_get_productcode($pid) { global $sql_tbl; $tbl = 'variants'; $field = 'variantid'; $tmp = func_query_first_cell("SELECT variantid FROM $sql_tbl[pricing] WHERE priceid = '$pid'"); if ($tmp == 0) { $tmp = func_query_first_cell("SELECT productid FROM $sql_tbl[pricing] WHERE priceid = '$pid'"); $tbl = 'products'; $field = 'productid'; } $productcode = func_query_first_cell("SELECT productcode FROM $sql_tbl[$tbl] WHERE $field = '$tmp'"); return $productcode;}if ( $pricing_amount < 0 || !is_numeric($pricing_amount)) { $pricing_amount = 0;}$pricing_amount = floatval($pricing_amount);if ( $pricing_amount == 0 || (empty($cats) && empty($mans))) { $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_error') ; $top_message['type'] = 'E'; $mode = ''; func_header_location($current_location . '/admin/products_bulk_pricing.php?err=1');}$join = array();$where = array();if (!empty($mans)) { $mans = implode(',', $mans); $where[] = "$sql_tbl[products].manufacturerid IN ($mans)";}if (!empty($cats)) { $cats = implode(',', $cats); if ($only_main_cat == 'Y') { $where[] = "$sql_tbl[products_categories].categoryid IN ($cats) AND $sql_tbl[products_categories].main = 'Y'"; } else { $where[] = "$sql_tbl[products_categories].categoryid IN ($cats)"; } $join[] = "LEFT JOIN $sql_tbl[products_categories] ON $sql_tbl[products].productid = $sql_tbl[products_categories].productid";}$join = implode(' ', $join);$where = empty($where) ? '' : 'WHERE ' . implode(' AND ', $where);$productids = func_query_column("SELECT $sql_tbl[products].productid FROM $sql_tbl[products] $join $where");unset($where);if (!empty($productids)) { $skipped_products = array(); $where = array(); $where[] = "productid IN (" . implode(',', $productids) . ")"; if (!empty($pricing_wholesale)) { $where[] = 'quantity = 1'; } if (!empty($memberships)) { $memberships = implode(',', $memberships); $where[] = "membershipid IN ($memberships)"; } $where = empty($where) ? '' : 'WHERE ' . implode(' AND ', $where); $priceids = func_query("SELECT priceid, price FROM $sql_tbl[pricing] $where"); if (!empty($priceids)) { foreach ($priceids as $k=>$v) { if ($pricing_type == 'percent') { $diff = $v['price'] * $pricing_amount / 100; } elseif ($pricing_type == 'fixed') { $diff = $pricing_amount; } if ($pricing_direction == 'up') { $newprice = $v['price'] + $diff; } elseif ($pricing_direction == 'down') { $newprice = $v['price'] - $diff; } if (!empty($pricing_round)) { $newprice = round($newprice); } if ($newprice <= 0) { $skipped_products[] = csi_get_productcode($v['priceid']); continue; } db_query("UPDATE $sql_tbl[pricing] SET price = $newprice WHERE priceid = " . $v['priceid']); } foreach ($productids as $p) { func_build_quick_prices($p); func_build_quick_flags($p); } $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_updated '); $top_message['type'] = 'I'; $smarty->assign('skipped_products', $skipped_products); } else { $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_no_prod ucts'); $top_message['type'] = 'I'; } } else { $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_no_prod ucts'); $top_message['type'] = 'I';}func_header_location($current_location . '/admin/products_bulk_pricing.php');

cheap eyeglasses 02-03-2020 02:52 PM

Re: How to bulk change the price of ALL product
 
run mysql via phpmyadmin

cflsystems 02-03-2020 03:44 PM

Re: How to bulk change the price of ALL product
 
Quote:

Originally Posted by voodoo1967
Is the mod 4.7.11 ready ?

Just ran the install - sql patches success, files uploaded ok, and file changes ok - cleared cache. Created a dummy directory and product. Applied bulk discount - increased by $1

and got this in the admin dashboard :-

* @copyright Copyright (c) 2015 CFL Systems, Inc. All rights reserved. * @license CFL Systems Software License Agreement - https://www.cflsystems.com/software-license-agreement.html * @link https://www.cflsystems.com/products-bulk-prices-for-x-cart-classic.html */if ( !defined('XCART_START') ) { header("Location: ../../"); die("Access denied"); }function csi_get_productcode($pid) { global $sql_tbl; $tbl = 'variants'; $field = 'variantid'; $tmp = func_query_first_cell("SELECT variantid FROM $sql_tbl[pricing] WHERE priceid = '$pid'"); if ($tmp == 0) { $tmp = func_query_first_cell("SELECT productid FROM $sql_tbl[pricing] WHERE priceid = '$pid'"); $tbl = 'products'; $field = 'productid'; } $productcode = func_query_first_cell("SELECT productcode FROM $sql_tbl[$tbl] WHERE $field = '$tmp'"); return $productcode;}if ( $pricing_amount < 0 || !is_numeric($pricing_amount)) { $pricing_amount = 0;}$pricing_amount = floatval($pricing_amount);if ( $pricing_amount == 0 || (empty($cats) && empty($mans))) { $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_error') ; $top_message['type'] = 'E'; $mode = ''; func_header_location($current_location . '/admin/products_bulk_pricing.php?err=1');}$join = array();$where = array();if (!empty($mans)) { $mans = implode(',', $mans); $where[] = "$sql_tbl[products].manufacturerid IN ($mans)";}if (!empty($cats)) { $cats = implode(',', $cats); if ($only_main_cat == 'Y') { $where[] = "$sql_tbl[products_categories].categoryid IN ($cats) AND $sql_tbl[products_categories].main = 'Y'"; } else { $where[] = "$sql_tbl[products_categories].categoryid IN ($cats)"; } $join[] = "LEFT JOIN $sql_tbl[products_categories] ON $sql_tbl[products].productid = $sql_tbl[products_categories].productid";}$join = implode(' ', $join);$where = empty($where) ? '' : 'WHERE ' . implode(' AND ', $where);$productids = func_query_column("SELECT $sql_tbl[products].productid FROM $sql_tbl[products] $join $where");unset($where);if (!empty($productids)) { $skipped_products = array(); $where = array(); $where[] = "productid IN (" . implode(',', $productids) . ")"; if (!empty($pricing_wholesale)) { $where[] = 'quantity = 1'; } if (!empty($memberships)) { $memberships = implode(',', $memberships); $where[] = "membershipid IN ($memberships)"; } $where = empty($where) ? '' : 'WHERE ' . implode(' AND ', $where); $priceids = func_query("SELECT priceid, price FROM $sql_tbl[pricing] $where"); if (!empty($priceids)) { foreach ($priceids as $k=>$v) { if ($pricing_type == 'percent') { $diff = $v['price'] * $pricing_amount / 100; } elseif ($pricing_type == 'fixed') { $diff = $pricing_amount; } if ($pricing_direction == 'up') { $newprice = $v['price'] + $diff; } elseif ($pricing_direction == 'down') { $newprice = $v['price'] - $diff; } if (!empty($pricing_round)) { $newprice = round($newprice); } if ($newprice <= 0) { $skipped_products[] = csi_get_productcode($v['priceid']); continue; } db_query("UPDATE $sql_tbl[pricing] SET price = $newprice WHERE priceid = " . $v['priceid']); } foreach ($productids as $p) { func_build_quick_prices($p); func_build_quick_flags($p); } $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_updated '); $top_message['type'] = 'I'; $smarty->assign('skipped_products', $skipped_products); } else { $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_no_prod ucts'); $top_message['type'] = 'I'; } } else { $top_message['content'] = func_get_langvar_by_name('txt_bulk_pricing_no_prod ucts'); $top_message['type'] = 'I';}func_header_location($current_location . '/admin/products_bulk_pricing.php');





This is spitting out the content of the php file instead of running it.
Check what you have uploaded and that the actual files are php files. Are you running this on a working cart or newly installed test cart? If new make sure the server knows it has to process php files as php files and not just dump their content in the browser.

voodoo1967 02-04-2020 01:30 AM

Re: How to bulk change the price of ALL product
 
1 Attachment(s)
Yep running on a live cart - 4.7.11
Re checked files and uploaded again, uninstalled and re installed .sql patch via phpmyadmin - screen shot attached and cleared cache - still get the issue in the xcart dashboard - and when I load up the module - make the change - the changes arent made etc.

Triple checked this now and all is as according to the instructions :( , I cant see that Ive missed anything

cheap eyeglasses 02-04-2020 01:42 AM

Re: How to bulk change the price of ALL product
 
Remember to backup your database first before you run any mysql commands.

cflsystems 02-04-2020 04:08 AM

Re: How to bulk change the price of ALL product
 
I don't know what to tell you but it looks like you are missing something. I would guess the files did not upload correctly to the server. The output you posted starts with


* @copyright Copyright (c) 2


which is not how it should be.
The file has to start with <?php

voodoo1967 02-04-2020 06:36 AM

Re: How to bulk change the price of ALL product
 
The only place where there is that string ie * @copyright Copyright (c) 2 is in the install and uninstall .sql files. I ran the uninstall sql then ran the install script.

Deleted the upload files and re uploaded them again and double checked the files that needed to be edited. All exactly as per instructions.

So Im giving up - the time spent on this I could have done it manually (I have the global product options module) - by changing the price product option into a global option and then changing the appropriate products to use that global option group.

cflsystems 02-04-2020 09:59 AM

Re: How to bulk change the price of ALL product
 
Quote:

Originally Posted by voodoo1967
The only place where there is that string ie * @copyright Copyright (c) 2 is in the install and uninstall .sql files.





That's not the case. I don't know where you got the installation pack from but this and other php doc lines are at the top of every file within the installation pack. If you are checking the file son the server and not seeing them then your upload is incorrect

voodoo1967 02-04-2020 10:34 AM

Re: How to bulk change the price of ALL product
 
Apologies Steve - you are correct - there was an error in my search
All the module files have "{* vim: set ts=2 sw=2 sts=2 et: *}

{**
* Products Bulk Prices Module
*
* @category X-Cart Classic Module
* @author CFL Systems, Inc. <support@cflsystems.com>
* @copyright Copyright (c) 2015 CFL Systems, Inc. All rights reserved.
" etc etc
I got the install pack from cfl (I previously purchased it) but I think during an upgrade it was missed - so I re downloaded it yesterday order #12968

So not sure how or what's up with it. I backed out the changes, re uploaded the files again and edited the various files etc done in notepad++ , cleared the xcart cache but got the exact same result

cflsystems 02-04-2020 11:30 AM

Re: How to bulk change the price of ALL product
 
What you are quoting now is from a template file. Previous output was from php file.
What you are seeing in the browser is the php file not the template file

illinismitty 02-04-2020 01:03 PM

Re: How to bulk change the price of ALL product
 
I hate the bulk edit in xcart 5. It's far too limited for those of us that do not code. They went backwards on this one.

voodoo1967 02-04-2020 02:19 PM

Re: How to bulk change the price of ALL product
 
It's ok Steve - Ive given up, I only have a few products that need updating - so will do it via global product options module instead. We have decided to probably migrate everything to ecwid once we have a spare weekend.
xcart has become too much of a bind to us. And the time spent on things like this means we arent focusing on trying to grow sales.


All times are GMT -8. The time now is 03:17 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.