Deletes a product SKU
@param integer $product_id
@param array $options
@todo Refactor
@return boolean
333042
public function delete($product_id, array $options = array())
    {
        $result = null;
        $this->hook->attach('sku.delete.before', $product_id, $options, $result, $this);

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

        $sql = 'DELETE FROM product_sku WHERE product_id=?';

        if (!empty($options['combinations'])) {
            $sql .= ' AND LENGTH(combination_id) > 0';
        }

        if (!empty($options['base'])) {
            $sql .= ' AND LENGTH(combination_id) = 0';
        }

        $result = (bool) $this->db->run($sql, array($product_id))->rowCount();
        $this->hook->attach('sku.delete.after', $product_id, $options, $result, $this);
        return (bool) $result;
    }
589695
public function actionRemoveCombination(int $combinationId)
    {
        $combination = Combination::findOne($combinationId);
        if (empty($combination)) throw new NotFoundHttpException('Such combination does not exists');
        $productId = $combination->product_id;

        if (!empty($combination)) {
            $combination->delete();
            if (Combination::find()->where(['product_id' => $productId])->count() == 1) {
                $combination = Combination::find()->where(['product_id' => $productId])->one();
                $combination->default = 1;
                if ($combination->validate()) $combination->save();
            }

            $eventName = self::EVENT_AFTER_EDIT_PRODUCT;
            $this->trigger($eventName, new ProductEvent([
                'id' => $combination->product_id
            ]));

        } else throw new NotFoundHttpException();

        return $this->redirect(\Yii::$app->request->referrer);
    }
65277
protected function deleteProductClass()
    {
        $this->controlAccess('product_class_delete');

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

        $this->redirect('', $this->text('Product class has not been deleted'), 'warning');
    }
703977
public function delete($productId, $force = null)
    {
        $options = (object)[];
        $options->qs = [ "force" => ($force ? "true" : "false") ];

        return $this->client->delete("/products/" . rawurlencode($productId), null, $options);
    }
500959
public function deleteFromProductCompare($compare_action_model)
    {
        $product_id = $this->getSubmitted('product_id');
        $result = $compare_action_model->delete($product_id);

        if ($this->isAjax()) {
            $this->outputJson($result);
        }

        $this->controlDeleteProductCompare($result, $product_id);
        $this->redirect($result['redirect'], $result['message'], $result['severity']);
    }
114435
public function canDelete($store_id)
    {
        if ($this->isDefault($store_id)) {
            return false;
        }

        $sql = 'SELECT NOT EXISTS (SELECT store_id FROM product WHERE store_id=:id)
                AND NOT EXISTS (SELECT store_id FROM category_group WHERE store_id=:id)
                AND NOT EXISTS (SELECT store_id FROM page WHERE store_id=:id)
                AND NOT EXISTS (SELECT store_id FROM orders WHERE store_id=:id)
                AND NOT EXISTS (SELECT store_id FROM cart WHERE store_id=:id)
                AND NOT EXISTS (SELECT store_id FROM user WHERE store_id=:id)';

        return (bool) $this->db->fetchColumn($sql, array('id' => $store_id));
    }
728915
public function deleteProductAddonAction($productId, $addonId)
    {
        $this->getManager()->deleteProductAddon($productId, $addonId);
        $this->getDoctrine()->getManager()->flush();

        $view = $this->view();

        return $this->handleView($view);
    }
383659
protected function updateProductClass($product_class_id)
    {
        if (!$this->isError() && !$this->product_class->update($product_class_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
325499
public function delete($product_id)
    {
        $result = null;
        $this->hook->attach('product.compare.delete.before', $product_id, $result, $this);

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

        $compared = $this->getList();

        if (empty($compared)) {
            return false;
        }

        $product_ids = array_flip($compared);
        unset($product_ids[$product_id]);

        $result = $this->set(array_keys($product_ids));
        $this->hook->attach('product.compare.delete.after', $product_id, $result, $this);
        return (bool) $result;
    }
808499
public function reduceProductStock($productId, $quantity, array $skuInfo = null)
    {
        $result = $this->httpRaw(self::WECHAT_SHOP_PRODUCT_STOCK_REDUCE_URL . 'access_token=' . $this->getAccessToken(), [
            'product_id' => $productId,
            'quantity' => $quantity,
            'sku_info' => $skuInfo === null ? $skuInfo : implode(':', $skuInfo)
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success';
    }
146014
public function delete($publicId, $options = [])
    {
        if (!$this->enabled()) {
            return false;
        }

        list($type, $resourceType, $transformation, $format) = self::optionsToParameters($options);

        return $this->cacheAdapter->delete($publicId, $type, $resourceType, $transformation, $format);
    }
737201
public function deleteAction($id)
    {
        $product = $this->container->get('vespolina.product_manager')->findProductById($id);

        if (!$product) {
            throw new NotFoundHttpException('The product does not exist!');
        }

        $dm = $this->container->get('doctrine.odm.mongodb.document_manager');
        $dm->remove($product);
        $dm->flush();

        $this->setFlash('vespolina_product_deleted', 'success');
        $url = $this->container->get('router')->generate('vespolina_product_list');
        return new RedirectResponse($url);
    }
460623
public function set($product_id, array $products)
    {
        $this->delete(array('product_id' => $product_id));

        $added = $count = 0;
        foreach ($products as $product) {

            $count++;

            $data = array(
                'product_id' => $product_id,
                'item_product_id' => $product['product_id']
            );

            if ($this->add($data)) {
                $added++;
            }
        }

        return $count && $added == $count;
    }
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;
    }
30004
public function removeProductOptionValue(\Dywee\ProductBundle\Entity\ProductOptionValue $productOptionValue)
    {
        $this->productOptionValues->removeElement($productOptionValue);
    }
222322
public function delete(ProductDeleteEvent $event)
    {
        if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) {
            $con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
            $con->beginTransaction();

            try {
                $fileList = ['images' => [], 'documentList' => []];

                // Get product's files to delete after product deletion
                $fileList['images']['list'] = ProductImageQuery::create()
                    ->findByProductId($event->getProductId());
                $fileList['images']['type'] = TheliaEvents::IMAGE_DELETE;

                $fileList['documentList']['list'] = ProductDocumentQuery::create()
                    ->findByProductId($event->getProductId());
                $fileList['documentList']['type'] = TheliaEvents::DOCUMENT_DELETE;

                // Delete product
                $product
                    ->setDispatcher($this->eventDispatcher)
                    ->delete($con)
                ;

                $event->setProduct($product);

                // Dispatch delete product's files event
                foreach ($fileList as $fileTypeList) {
                    foreach ($fileTypeList['list'] as $fileToDelete) {
                        $fileDeleteEvent = new FileDeleteEvent($fileToDelete);
                        $this->eventDispatcher->dispatch($fileTypeList['type'], $fileDeleteEvent);
                    }
                }

                $con->commit();
            } catch (\Exception $e) {
                $con->rollBack();
                throw $e;
            }
        }
    }
838561
public function setProductID($productID) {
        if (empty($productID))
            throw new Exception('Product ID must be set and cannot be empty.');

        $this->productID = trim($productID);

        return $this;
    }