Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
675 B
3
Indexable
Never
  private static function saveSimpleVariant($product_ps, $variant, $sync) {
    if ($variants_ps = $product_ps->getWsCombinations()) {
      foreach ($variants_ps as $variant_ps) {
        (new \Combination($variant_ps["id"]))->delete();
      }
    }
    if ($sync["stock"]) {
      \StockAvailable::setQuantity($product_ps->id, 0, $variant->quantity);
    }
    $product_ps->ean13 = $sync["barcode"] ? $variant->barcode : $product_ps->ean13;
    $product_ps->save();
    $variantC = new \CentryPs\models\homologation\SimpleProductVariant($product_ps->id, $variant->_id);
    $variantC->save();
    error_log("Homologación producto simple:" . print_r($variantC, true));
  }