Answer the question
In order to leave comments, you need to log in
How to add a price when adding a product outside the webasyst framework?
How to add a price when adding a product outside the webasyst framework?
Products are now added like this:
$price = isset($data['price'])?$data['price']:0;
$product = new shopProduct();
foreach ($data as $key => $value) {
$product->setData($key, $value);
}
$product->save();
$product_skus = new shopProductSkusModel();
$skus = $product_skus->getDataByProductId($product->getId(), true);
foreach ($skus as $sku_key => $sku_data){
$product_skus->updateById($sku_key, [
'price' => $price,
'available' => 1
]);
}
$product = new shopProduct($product->getId());
$product->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