Answer the question
In order to leave comments, you need to log in
Changes to the xpdo database are not saved, how to fix it?
Changes are not saved when modifying MODX objects
$state = $modx->getObject('StorageState', array('slot' => $move->slot_a->name, 'good_uuid' => $good->uuid));
if($state) {
$state_A_New_Count = $state->good_count - $move->count;
if($state_A_New_Count >= 0) {
$state->set('good_count', $state_A_New_Count);
} else {
$state->set('good_count', $state_A_New_Count);
}
$state->save();
} else {
// Источник не определён, Сохраняем дефицит
$state = $modx->newObject('StorageState');
$state->fromArray([
'slot' => $move->slot_a->name,
'good_uuid' => $good->uuid,
'good_count' => -$move->count
]);
$state->save();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question