Answer the question
In order to leave comments, you need to log in
How to change the price of all products from a certain category in minishop2?
Hello, I need to change the bulk prices for all products from the category with id 24.
Increase the price by 8%?
$product = $modx->getObject('msProduct', тут id);
$oldPrice = $product->get('price');
$product->set('price', $oldPrice + $oldPrice*0.08);
Answer the question
In order to leave comments, you need to log in
$query = $modx->newQuery('msProduct');
$query->limit(10000);
$query->where(array(
'parent' => 4, // тут ID категории
));
$docs = $modx->getCollection('msProduct',$query);
foreach($docs as $doc){
$oldPrice = $doc->get('price');
$doc->set('price', $oldPrice + $oldPrice*0.08);
$doc->save();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question