Jump to content

Bulk Increase price % for a category, its subcategories and products


irl
 Share

Recommended Posts

Hello,
Would anybody know, how to increase prices (bulk %) in a selected Category all its subcategories and products
I made a function in classes/products.php

public function categoryName($id_category)
{
$sql ='SELECT `name`
FROM `'._DB_PREFIX_.'category_lang`
WHERE `id_category` = '.intval($id_category);
$result = Db::getInstance()->getRow($sql);
return $result['name'];
}

I am trying to get:
if ($Category = Product::categoryName($Product['id_category_default']) {... selected categories A, B, C ...
$Price = Product::getPriceStatic(intval($Product['id_product']))*1.25; }
elseif ($Category = Product::categoryName($Product['id_category_default'])){
$Price = Product::getPriceStatic(intval($Product['id_product'])); }

Above would increase all prices in all categories.
Can anybody help? Thank you

Share this post


Link to post
Share on other sites

Php for me is like salt in my eyes
Spent >3 hours and still cannot get it work

Works in asp flawless however in php "if" returns false always
Changed to strcmp returns true always

$itemarr = array( 'blam a', 'blam b');

foreach ($Products AS $Product)
{
if ($Product['active'] and $Product['price']!=0) {
$Price = Product::getPriceStatic(floatval($Product['id_product']));
$Category = Product::categoryName($Product['id_category_default']);

foreach ($itemarr AS $myarr){
If((string)$myarr == (string)$Category)
$Price *= 1.25;
}

Any idea why?

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More