D
D
Dmitry Baskakov2020-05-29 09:53:04
PHP
Dmitry Baskakov, 2020-05-29 09:53:04

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();


But in this method, saving the price does not work.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question