Removes relation between variant and attribute.

@param int $productId
@param int $attributeId

@throws ProductException

@return ProductInterface
513540
public function removeVariantAttributeRelation($productId, $attributeId)
    {
        $variant = $this->retrieveProductById($productId);
        $attribute = $this->retrieveAttributeById($attributeId);

        if (!$variant->getVariantAttributes()->contains($attribute)) {
            throw new ProductException('Variant does not have relation to attribute');
        }

        $variant->removeVariantAttribute($attribute);

        return $variant;
    }
588914
private function getStoreData($productId, $storeId, $attributeCode)
    {
        if (array_key_exists($productId, $this->attributeData)
            && array_key_exists($storeId, $this->attributeData[$productId])
            && array_key_exists($attributeCode, $this->attributeData[$productId][$storeId])
        ) {
            return $this->attributeData[$productId][$storeId][$attributeCode];
        }

        return null;
    }
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;
    }
1261446
public function removeRole($contentId, $roleId)
    {
        try {
            return $this->innerGateway->removeRole($contentId, $roleId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
839133
public function deleteAction($parentId, $variantId)
    {
        $variant = $this->getProductVariantManager()->deleteVariant($variantId);

        if ($variant->getParent()->getId() !== (int) $parentId) {
            throw new ProductException('Variant does not exists for given product.');
        }
        $this->getEntityManager()->flush();

        $view = $this->view(null, 204);

        return $this->handleView($view);
    }
1129298
protected function removeListItems( $productId )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'product/lists' );

		$search = $manager->createSearch();
		$expr = array(
			$search->compare( '==', 'product.lists.parentid', $productId ),
			$search->compare( '==', 'product.lists.domain', 'product' ),
			$search->compare( '==', 'product.lists.type', 'bought-together' ),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );

		$listItems = $manager->searchItems( $search );

		$manager->deleteItems( array_keys( $listItems ) );
	}
527748
public function actionRemove(int $productId, int $combinationId = null)
    {
        \Yii::$app->cart->removeItem($productId, $combinationId);
        return $this->redirect(\Yii::$app->request->referrer);
    }
674331
public function setStatusForProduct(ProductInterface $product, $statusId)
    {
        // Check if status has changed.
        if ($product->getStatus() && $product->getStatus()->getId() === $statusId) {
            return;
        }

        $status = $this->statusRepository->find($statusId);
        if (!$status) {
            throw new ProductDependencyNotFoundException(self::$productStatusEntityName, $statusId);
        }

        // Set new status to product.
        $product->setStatus($status);

        // If product has variants, set status for all variants as well.
        if ($product->getType()
            && $product->getType()->getId() === (int) $this->productTypesMap['PRODUCT_WITH_VARIANTS']
        ) {
            $variants = $this->productRepository->findByParent($product);
            foreach ($variants as $variant) {
                $variant->setStatus($status);
            }
        }
    }
917174
public function removeRole($contentId, $roleId)
    {
        $query = $this->handler->createDeleteQuery();
        $query
            ->deleteFrom($this->handler->quoteTable('ezuser_role'))
            ->where(
                $query->expr->lAnd(
                    $query->expr->eq(
                        $this->handler->quoteColumn('contentobject_id'),
                        $query->bindValue($contentId, null, \PDO::PARAM_INT)
                    ),
                    $query->expr->eq(
                        $this->handler->quoteColumn('role_id'),
                        $query->bindValue($roleId, null, \PDO::PARAM_INT)
                    )
                )
            );
        $query->prepare()->execute();
    }
1224758
public function delete($product_id)
    {
        $result = null;
        $this->hook->attach('product.compare.delete.product.before', $product_id, $result, $this);

        if (!empty($result)) {
            return (array) $result;
        }

        if (!$this->compare->delete($product_id)) {
            return $this->getResultError();
        }

        $result = $this->getResultDeleted();
        $this->hook->attach('product.compare.delete.product.after', $product_id, $result, $this);
        return (array) $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);
    }
308093
public function removeReverseFieldRelations($contentId)
    {
        $query = $this->dbHandler->createSelectQuery();
        $query
            ->select('ezcontentobject_attribute.*')
            ->from('ezcontentobject_attribute')
            ->innerJoin(
                'ezcontentobject_link',
                $query->expr->lAnd(
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('from_contentobject_id', 'ezcontentobject_link'),
                        $this->dbHandler->quoteColumn('contentobject_id', 'ezcontentobject_attribute')
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link'),
                        $this->dbHandler->quoteColumn('version', 'ezcontentobject_attribute')
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('contentclassattribute_id', 'ezcontentobject_link'),
                        $this->dbHandler->quoteColumn('contentclassattribute_id', 'ezcontentobject_attribute')
                    )
                )
            )
            ->where(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('to_contentobject_id', 'ezcontentobject_link'),
                    $query->bindValue($contentId, null, PDO::PARAM_INT)
                ),
                $query->expr->gt(
                    $query->expr->bitAnd(
                        $this->dbHandler->quoteColumn('relation_type', 'ezcontentobject_link'),
                        $query->bindValue(8, null, PDO::PARAM_INT)
                    ),
                    0
                )
            );

        $statement = $query->prepare();
        $statement->execute();

        while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
            if ($row['data_type_string'] === 'ezobjectrelation') {
                $this->removeRelationFromRelationField($row);
            }

            if ($row['data_type_string'] === 'ezobjectrelationlist') {
                $this->removeRelationFromRelationListField($contentId, $row);
            }
        }
    }
714860
public function isContainsProduct($productId, $combinationId = null)
    {
        if (Yii::$app->user->isGuest) {
            if (!empty(Yii::$app->session[self::SESSION_KEY])) {
                $sessionProducts = Yii::$app->session[self::SESSION_KEY];

                foreach ($sessionProducts as $item) {
                    $condition = (empty($combinationId))
                        ? (ArrayHelper::getValue($item, 'id') == $productId)
                        : (ArrayHelper::getValue($item, 'id') == $productId && ArrayHelper::getValue($item, 'combinationId') == $combinationId);

                    if($condition) {
                        return $condition;
                    }
                }
            }
        } else {
            /** @var Order $order */
            $order = Order::find()
                ->where(['user_id' => Yii::$app->user->id, 'status' => OrderStatus::STATUS_INCOMPLETE])
                ->one();

            if (!empty($order)) {
                $condition = (empty($combinationId))
                    ? ['order_id' => $order->id, 'product_id' => $productId]
                    : ['order_id' => $order->id, 'product_id' => $productId, 'combination_id' => $combinationId];

                $product = OrderProduct::find()
                    ->where($condition)
                    ->one();

                return (!empty($product));
            }
        }

        return false;
    }
832865
public function removePolicyLimitations($policyId)
    {
        try {
            return $this->innerGateway->removePolicyLimitations($policyId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1214945
public function rebuildStoreIndex($storeId, $productIds = null)
    {
        $productId = 0;

        // Magento is only sending children ids here. Ensure to reindex also the parents product ids, if any.
        if (!empty($productIds)) {
            $productIds = array_unique(array_merge($productIds, $this->resourceModel->getRelationsByChild($productIds)));
        }

        do {
            $products = $this->getSearchableProducts($storeId, $productIds, $productId);

            foreach ($products as $productData) {
                $productId = (int) $productData['entity_id'];
                $productData['has_options']      = (bool) $productData['has_options'];
                $productData['required_options'] = (bool) $productData['required_options'];
                yield $productId => $productData;
            }
        } while (!empty($products));
    }
1374001
public function loadProductById($productId)
    {
        $collection = $this->catalogCollection->create()
            ->addFieldToFilter('product_id', $productId)
            ->setPageSize(1);

        return $collection->getFirstItem();
    }
918706
public function showAction($attributeId, $id)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Attribute $attribute */
        $attribute = $em->getRepository('EcommerceBundle:Attribute')->find($attributeId);

        if (!$attribute) {
            throw $this->createNotFoundException('Unable to find Attribute entity.');
        }

        /** @var AttributeValue $entity */
        $entity = $em->getRepository('EcommerceBundle:AttributeValue')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find AttributeValue entity.');
        }

        $deleteForm = $this->createDeleteForm($attributeId, $id);

        return array(
            'entity'      => $entity,
            'attribute'   => $attribute,
            'delete_form' => $deleteForm->createView(),
        );
    }