/*
After insert/update of a productuom,
check all uoms belonging to that product,
if any productuom is enabled, enable the product,
otherwise, disable it.
426843
public function insertProductUom($e)
    {
        $dbResult = $e->getParam('result');
        if (!count($dbResult)) {
            return; //no rows affected
        }

        $productId      = is_array($e->getParam('data'))
                        ? $e->getParam('data')['product_id']
                        : $e->getParam('data')->getProductId();
        $productService = $e->getTarget()->getProductService();
        $find           = array('product_id' => $productId);
        $product        = $productService->find($find, array('uoms'));

        $enabled = $this->canProductBeEnabled($product);

        $productService->setEnabledProduct($productId, $enabled);
    }
245817
protected function deleteProduct()
    {
        $this->controlAccess('product_delete');

        if ($this->product->delete($this->data_product['product_id'])) {
            $this->redirect('admin/content/product', $this->text('Product has been deleted'), 'success');
        }

        $this->redirect('', $this->text('Product has not been deleted'), 'warning');
    }
776304
public Completable addProduct(Product product) {
    List<Product> updatedShoppingCart = new ArrayList<>();
    updatedShoppingCart.addAll(itemsInShoppingCart.getValue());
    updatedShoppingCart.add(product);
    itemsInShoppingCart.onNext(updatedShoppingCart);
    return Completable.complete();
  }
186852
protected function validateEditProductBundle()
    {
        $this->setSubmitted('product');
        $this->setSubmitted('product_id', $this->data_product['product_id']);

        $this->validateComponent('product_bundle');

        return !$this->hasErrors();
    }
204924
public void uninstall(boolean checkDependency, String[] productIds, Collection<File> toBeDeleted) throws InstallException {
        getUninstallDirector().uninstall(checkDependency, productIds, toBeDeleted);
    }
345061
function onAddedExtensions (extensions) {
  console.log('Detected the following additions: ', extensions);

  extensions.forEach(function (ext) {

    if (this.isExtensionAlreadyProcessed(ext)) return;

    this.isExtensionSupported(ext).done(function (isSupported) {
      if (! isSupported) return;

      this.processAdditionalExtension(ext);

    }.bind(this));

  }.bind(this));
}
1228437
function () {

    var items = Array.prototype.slice.call(arguments);
    this.source.unshift.apply(this.source, items);
    this._updateInfo();

    // DEPRECATED
    this.emit("insert", items[0], 0);
    this.emit("update", { insert: items });
  }
101321
protected function validateRelatedProduct()
    {
        $field = 'related';

        if ($this->isExcluded($field) || $this->isError('store_id')) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if (empty($value)) {
            $this->setSubmitted($field, array());
            return null;
        }

        $store_id = $this->getSubmitted('store_id');

        $product_ids = array();

        foreach (array_unique($value) as $product_id) {

            $product = $this->product->get($product_id);

            if (empty($product['store_id'])) {
                $this->setError($field, $this->translation->text('Some of related products are invalid'));
                return false;
            }

            if ($product['store_id'] != $store_id) {
                $this->setError($field, $this->translation->text('All related product must belong to the same store'));
                return false;
            }

            $product_ids[$product['product_id']] = $product['product_id'];
        }

        $updating = $this->getUpdating();

        if (isset($updating['product_id'])) {
            // Exclude the current product from the related products
            unset($product_ids[$updating['product_id']]);
        }

        $this->setSubmitted('related', $product_ids);
        return true;
    }
258928
protected function updateProductClassField($product_class_field_id)
    {
        if (!$this->isError() && !$this->product_class_field->update($product_class_field_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
688629
public function delete($product_id)
    {
        $result = null;
        $this->hook->attach('product.related.delete.before', $product_id, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        foreach (array('product_id', 'item_product_id') as $field) {
            if (!$this->db->delete('product_related', array($field => $product_id))) {
                return false;
            }
        }

        $this->hook->attach('product.related.delete.after', $product_id, $result, $this);
        return (bool) $result;
    }
771565
protected void updateStatus() {
        if (!plugins.isEmpty()) {
            boolean disabled = isDisabled();
            
            for (ElementPlugin container : plugins) {
                container.setDisabled(disabled);
            }
        }
    }
238362
def enable(self):
        
        self.update(antivirus_enabled=True,
                    virus_mirror='update.nai.com/Products/CommonUpdater' if \
                        not self.get('virus_mirror') else self.virus_mirror,
                    antivirus_update_time=self.antivirus_update_time if \
                        self.get('antivirus_update_time') else 21600000)
973244
public static function enable()
    {
        Builder::macro(self::MACRO_METHOD, function (Fluent $builder, $createdAt = 'createdAt', $updatedAt = 'updatedAt', $type = 'dateTime') {
            $builder->{$type}($createdAt)->timestampable()->onCreate();
            $builder->{$type}($updatedAt)->timestampable()->onUpdate();
        });
    }
790197
public static function updateProduct($e)
    {
        $productService = $e->getTarget();
        $choiceService  = $productService->getChoiceService();

        $where = $e->getParam('where');
        $products = $productService->findMany($where, array('uoms'));

        foreach ($products as $product) {
            $productId = $product->getProductId();
            $enabled   = ($product->getEnabled()) ? 1 : 0;
            $choiceService->update(
                array('enabled'    => $enabled), //data
                array('product_id' => $productId)    //where
            );
        }

        $productIds = $e->getTarget();
    }
862073
public function onRestActionUpdateLicenseKeys()
    {
        if (!current_user_can($this->App->Config->§caps['§manage'])) {
            $this->s::dieForbidden(); // Disallow.
        }
        $apps_by_slug = $this->s::getAppsBySlug();
        $data         = (array) $this->s::restActionData('', true);
        $license_keys = (array) ($data['license_keys'] ?? []);
        $Errors       = $this->c::error();

        foreach ($license_keys as $_app_slug => $_license_key) {
            if (!$_app_slug || !is_string($_app_slug) || !is_string($_license_key)) {
                continue; // Bypass; invalid request data.
            } elseif (!($_App = $apps_by_slug[$_app_slug] ?? null)) {
                continue; // App is no longer active.
            }
            $_existing_license_key = $_App->s::getOption('§license_key');

            if ($_license_key) { // Activate (or reactivate) a license key.
                if ($_existing_license_key && $_existing_license_key !== $_license_key) {
                    $this->deactivate($_app_slug, $_existing_license_key);
                } // ↑ Deactivate existing license key.

                if ($this->c::isError($_Error = $this->activate($_app_slug, $_license_key))) {
                    $Errors->add($_Error->slug(), '**'.$_App->Config->©brand['§product_name'].':** '.$_Error->message());
                    $_App->s::updateOptions(['§license_key' => '']); // Empty; problem w/ license key.
                } else {
                    $_App->s::updateOptions(['§license_key' => $_license_key]);
                }
            } elseif (!$_license_key && $_existing_license_key) { // Deactivation.
                $this->deactivate($_app_slug, $_existing_license_key);
                $_App->s::updateOptions(['§license_key' => '']);
            }
        } // unset($_app_slug, $_license_key, $_App, $_existing_license_key, $_Error);

        if ($Errors->exist()) { // Display a full list of all errors.
            $notice_heading = __('Problem updating %1$s™ license keys:', 'wp-sharks-core');
            $notice_heading = sprintf($notice_heading, esc_html($this->App::CORE_CONTAINER_NAME));
            $notice_markup  = $this->s::menuPageNoticeErrors($notice_heading, $Errors->messages());
            $this->s::enqueueUserNotice($notice_markup, ['type' => 'error']);
        } else {
            $notice_markup = sprintf(__('%1$s™ license keys updated successfully.', 'wp-sharks-core'), esc_html($this->App::CORE_CONTAINER_NAME));
            $this->s::enqueueUserNotice($notice_markup, ['type' => 'success']);
        }
        wp_redirect($this->s::menuPageUrl()).exit(); // Stop on redirection.
    }
825470
public void setProductSubscriptions(java.util.Collection<String> productSubscriptions) {
        if (productSubscriptions == null) {
            this.productSubscriptions = null;
            return;
        }

        this.productSubscriptions = new java.util.ArrayList<String>(productSubscriptions);
    }
700283
private function check_if_enabled()
    {
        if ($this->config['enabled'] == true && extension_loaded('sqlite3')) {
            $this->enabled = true;
        } else {
            $this->enabled = false;
        }
    }