Hi. I'm looking for a script that will reduce every price in the store by a certain percentage (a variable that can be set). Each time I run the script (can cron job it as well) it will reduce every price in the shop by a percentage of itself.
If something costs $100 and the reduction is 2%, after the script is ran the new price would be $98. If I ran the script again the next day, the new price would be $96.04, then $94.11, and on and on. I'm not looking for a script that will reduce everything by the same percentage, but replaces the price of each item with a percent of itself. Have I confused you yet? Sorry.
I'd also like it to have a feature where everything in the store can be listed in one page (so admin can check all the prices at one time).
If something like that is not available I'm willing to pay someone to create such a script. Please send me a PM.
This functionality does not exist as you describe.
However, you could use the import/export module to export your catalog to a spreadsheet, modify all the prices and import the modified catalog back to the store. This process also gives you a global view of all prices from within the spreadsheet.
Obviously the import/export process does not lend itself to being driven by cron but I just wanted you to see an alternative.
cheers
Bruce
However, you could use the import/export module to export your catalog to a spreadsheet, modify all the prices and import the modified catalog back to the store. This process also gives you a global view of all prices from within the spreadsheet.
Obviously the import/export process does not lend itself to being driven by cron but I just wanted you to see an alternative.
cheers
Bruce
I suppose a php script like this:
http://drupal.org/node/50103
could be used with cron.. or simply by loading it once per day.
Just do a database query on all product prices
and for each loop to set product['price'] *= .02.
Something like:
http://drupal.org/node/50103
could be used with cron.. or simply by loading it once per day.
Just do a database query on all product prices
and for each loop to set product['price'] *= .02.
Something like:
Code: Select all
$products= $database->getRows("select product_id, price from product");
foreach ($products as $product) {
$sql = "update product set price = '?' where product_id= '?'";
$database->query($this->database->parse($sql, ($product[price] - ($product[price] * 0.02)), $product['product_id']));
}
Thanks for the quick response. I think the sql query would be the best way to go. It could even be written into a php file that can be run by cron. I'm not good at sql, though, and it appears there are some syntax errors in the above query. You probably just meant that as an example of a way to do it. Here's the error that was returned when I ran it on my test store:
Error
There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem
ERROR: Unknown Punctuation String @ 21
STR: ->
SQL: $products= $database->getRows("select product_id, price from product");$products= $database->getRows("select product_id, price from product");$products= $database->getRows("select product_id, price from product");$products= $database->getRows("select product_id, price from product");$products= $database->getRows("select product_id, price from product");
SQL query: Documentation
$products= $database->getRows("select product_id, price from product");
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$products= $database->getRows("select product_id, price from product")' at line 1
Shows how much I know...lol.
If I put it in a php file, how will the script know what sql db to run the query on?
*edit*
If I put it in a php file, how will the script know what sql db to run the query on?
*edit*
Fatal error: Call to a member function getRows() on a non-object in /home/eastcoa1/public_html/ecoastelectronics/pricetest/price_reduce.php on line 2
Last edited by Sledge69 on Thu Nov 20, 2008 11:31 pm, edited 1 time in total.
lol yea.. i guess you need the rest of the info
Try adding this to your admin/controller/product.php file
And call url:
http://www.xxxxxxx.com/admin/index.php? ... educePrice
It should return you back to the admin/product page but the prices should be 2%lower
(Not tested)
Try adding this to your admin/controller/product.php file
Code: Select all
function reducePrice() {
$response =& $this->locator->get('response');
$database =& $this->locator->get('database');
$url =& $this->locator->get('url');
$products= $database->getRows("select product_id, price from product");
foreach ($products as $product) {
$sql = "update product set price = '?' where product_id= '?'";
$database->query($database->parse($sql, ($product['price'] - ($product['price'] * 0.02)), $product['product_id']));
}
$response->redirect($url->ssl('product'));
}
http://www.xxxxxxx.com/admin/index.php? ... educePrice
It should return you back to the admin/product page but the prices should be 2%lower
(Not tested)
Last edited by Qphoria on Fri Nov 21, 2008 1:32 am, edited 1 time in total.
Well I'm happy to test it for you(Not tested)
Here's what it returned:
Looks like it doesn't like line 12.Notice: Undefined property: ControllerProduct::$database in /home/eastcoa1/public_html/ecoastelectronics/pricetest/admin/controller/product.php on line 12
Fatal error: Call to a member function parse() on a non-object in /home/eastcoa1/public_html/ecoastelectronics/pricetest/admin/controller/product.php on line 12
IT'S WORKING!
The prices are falling. Only now the url returns this:
The prices are falling. Only now the url returns this:
Notice: Use of undefined constant price - assumed 'price' in /home/eastcoa1/public_html/ecoastelectronics/pricetest/admin/controller/product.php on line 12
Notice: Use of undefined constant price - assumed 'price' in /home/eastcoa1/public_html/ecoastelectronics/pricetest/admin/controller/product.php on line 12
Notice: Use of undefined constant price - assumed 'price' in /home/eastcoa1/public_html/ecoastelectronics/pricetest/admin/controller/product.php on line 12
Notice: Use of undefined constant price - assumed 'price' in /home/eastcoa1/public_html/ecoastelectronics/pricetest/admin/controller/product.php on line 12
Notice: Use of undefined constant price - assumed 'price' in /home/eastcoa1/public_html/ecoastelectronics/pricetest/admin/controller/product.php on line 12
Notice: Use of undefined constant price - assumed 'price' in /home/eastcoa1/public_html/ecoastelectronics/pricetest/admin/controller/product.php on line 12
Notice: Use of undefined constant price - assumed 'price' in /home/eastcoa1/public_html/ecoastelectronics/pricetest/admin/controller/product.php on line 12
Notice: Use of undefined constant price - assumed 'price' in /home/eastcoa1/public_html/ecoastelectronics/pricetest/admin/controller/product.php on line 12
Warning: Cannot modify header information - headers already sent by (output started at /home/eastcoa1/public_html/ecoastelectronics/pricetest/admin/controller/product.php:12) in /home/eastcoa1/public_html/ecoastelectronics/pricetest/library/environment/response.php on line 22
It works perfectly! Thanks. I've had the same request on a few other shopping cart forums (Zen, OS) and no one seems interested. OC just got a new loyal fan. I'm moving some cash to PayPal as we speak, when the move is complete I'll donate to you and the project.
Thanks again. http://www.thepoliticalcapital.com/Smil ... tiphat.gif[/img]
Thanks again. http://www.thepoliticalcapital.com/Smil ... tiphat.gif[/img]
Who is online
Users browsing this forum: No registered users and 26 guests