Exemplo n.º 1
0
 public function deleteProducts(ConnectionInterface $con = null)
 {
     $productsCategories = ProductCategoryQuery::create()->filterByCategoryId($this->getId())->filterByDefaultCategory(1)->find($con);
     if ($productsCategories) {
         foreach ($productsCategories as $productCategory) {
             $product = $productCategory->getProduct();
             if ($product) {
                 $product->delete($con);
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Calculate next position relative to our default category
  */
 protected function addCriteriaToPositionQuery($query)
 {
     // Find products in the same category
     $produits = ProductCategoryQuery::create()->filterByCategoryId($this->getDefaultCategoryId())->filterByDefaultCategory(true)->select('product_id')->find();
     // Filtrer la requete sur ces produits
     if ($produits != null) {
         $query->filterById($produits, Criteria::IN);
     }
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  */
 protected function addCriteriaToPositionQuery(ProductCategoryQuery $query)
 {
     $query->filterByCategoryId($this->getCategoryId());
 }
Exemplo n.º 4
0
 /**
  * Overload for the position management
  * @param Base\ProductCategory $productCategory
  * @inheritdoc
  */
 protected function doAddProductCategory($productCategory)
 {
     parent::doAddProductCategory($productCategory);
     $productCategoryPosition = ProductCategoryQuery::create()->filterByCategoryId($productCategory->getCategoryId())->orderByPosition(Criteria::DESC)->findOne();
     $productCategory->setPosition($productCategoryPosition !== null ? $productCategoryPosition->getPosition() + 1 : 1);
 }