M
M
Maxim Chernykh2022-01-28 15:25:34
MODX
Maxim Chernykh, 2022-01-28 15:25:34

How to remove the checkbox from all products through the console?

I'm trying to uncheck the box popular with all products, alas, it doesn't work

<?php
$products = $modx->getIterator('msProduct', array("class_key" =>"msProduct"));
foreach($products as $product){
    $options = $product->getMany('Options');
    $options = array(
    	'popular' => 0,
    );
    $product->set('options', $options);
    $product->save();
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2022-02-03
@myskif

If this is a standard minishop popular field

<?php
$products = $modx->getIterator('msProductData');
foreach($products as $product){
    $product->set('popular', 0);
    $product->save();
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question