Merge branch 'master' of github.com:thelia/thelia
This commit is contained in:
48
core/lib/Thelia/Core/Event/CategoryAddContentEvent.php
Normal file
48
core/lib/Thelia/Core/Event/CategoryAddContentEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class CategoryAddContentEvent extends CategoryEvent
|
||||
{
|
||||
protected $content_id;
|
||||
|
||||
public function __construct(Category $category, $content_id)
|
||||
{
|
||||
parent::__construct($category);
|
||||
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
}
|
||||
48
core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php
Normal file
48
core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class CategoryDeleteContentEvent extends CategoryEvent
|
||||
{
|
||||
protected $content_id;
|
||||
|
||||
public function __construct(Category $category, $content_id)
|
||||
{
|
||||
parent::__construct($category);
|
||||
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
|
||||
public function getContentId()
|
||||
{
|
||||
return $this->content_id;
|
||||
}
|
||||
|
||||
public function setContentId($content_id)
|
||||
{
|
||||
$this->content_id = $content_id;
|
||||
}
|
||||
}
|
||||
@@ -153,6 +153,9 @@ final class TheliaEvents
|
||||
const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility";
|
||||
const CATEGORY_UPDATE_POSITION = "action.updateCategoryPosition";
|
||||
|
||||
const CATEGORY_ADD_CONTENT = "action.categoryAddContent";
|
||||
const CATEGORY_REMOVE_CONTENT = "action.categoryRemoveContent";
|
||||
|
||||
const BEFORE_CREATECATEGORY = "action.before_createcategory";
|
||||
const AFTER_CREATECATEGORY = "action.after_createcategory";
|
||||
|
||||
|
||||
@@ -53,8 +53,12 @@ class AssociatedContent extends Content
|
||||
{
|
||||
$argumentCollection = parent::getArgDefinitions();
|
||||
|
||||
$argumentCollection->addArgument(Argument::createIntTypeArgument('product'))
|
||||
->addArgument(Argument::createIntTypeArgument('category'));
|
||||
$argumentCollection
|
||||
->addArgument(Argument::createIntTypeArgument('product'))
|
||||
->addArgument(Argument::createIntTypeArgument('category'))
|
||||
->addArgument(Argument::createIntTypeArgument('exclude_product'))
|
||||
->addArgument(Argument::createIntTypeArgument('exclude_category'))
|
||||
;
|
||||
|
||||
$argumentCollection->get('order')->default = "associated_content";
|
||||
|
||||
@@ -91,6 +95,28 @@ class AssociatedContent extends Content
|
||||
$search->filterByCategoryId($category, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$exclude_product = $this->getExcludeProduct();
|
||||
|
||||
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
|
||||
if (null !== $exclude_product) {
|
||||
// Exclure tous les attribut qui sont attachés aux templates indiqués
|
||||
$search->filterById(
|
||||
ProductAssociatedContentQuery::create()->filterByProductId($exclude_product)->select('product_id')->find(),
|
||||
Criteria::NOT_IN
|
||||
);
|
||||
}
|
||||
|
||||
$exclude_category = $this->getExcludeCategory();
|
||||
|
||||
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
|
||||
if (null !== $exclude_category) {
|
||||
// Exclure tous les attribut qui sont attachés aux templates indiqués
|
||||
$search->filterById(
|
||||
CategoryAssociatedContentQuery::create()->filterByProductId($exclude_category)->select('category_id')->find(),
|
||||
Criteria::NOT_IN
|
||||
);
|
||||
}
|
||||
|
||||
$order = $this->getOrder();
|
||||
$orderByAssociatedContent = array_search('associated_content', $order);
|
||||
$orderByAssociatedContentReverse = array_search('associated_content_reverse', $order);
|
||||
|
||||
@@ -61,6 +61,7 @@ class Content extends BaseI18nLoop
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('folder'),
|
||||
Argument::createIntListTypeArgument('folder_default'),
|
||||
Argument::createBooleanTypeArgument('current'),
|
||||
Argument::createBooleanTypeArgument('current_folder'),
|
||||
Argument::createIntTypeArgument('depth', 1),
|
||||
@@ -97,9 +98,18 @@ class Content extends BaseI18nLoop
|
||||
}
|
||||
|
||||
$folder = $this->getFolder();
|
||||
$folderDefault = $this->getFolderDefault();
|
||||
|
||||
if (!is_null($folder) || !is_null($folderDefault)) {
|
||||
|
||||
if (!is_null($folder)) {
|
||||
$folders = FolderQuery::create()->filterById($folder, Criteria::IN)->find();
|
||||
}
|
||||
|
||||
if (!is_null($folderDefault)) {
|
||||
$folders = FolderQuery::create()->filterById($folderDefault, Criteria::IN)->find();
|
||||
}
|
||||
|
||||
if (!is_null($folder)) {
|
||||
$folders = FolderQuery::create()->filterById($folder, Criteria::IN)->find();
|
||||
|
||||
$depth = $this->getDepth();
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ class Product extends BaseI18nLoop
|
||||
)
|
||||
),
|
||||
Argument::createIntListTypeArgument('category'),
|
||||
Argument::createIntListTypeArgument('category_default'),
|
||||
Argument::createBooleanTypeArgument('new'),
|
||||
Argument::createBooleanTypeArgument('promo'),
|
||||
Argument::createFloatTypeArgument('min_price'),
|
||||
@@ -170,9 +171,16 @@ class Product extends BaseI18nLoop
|
||||
}
|
||||
|
||||
$category = $this->getCategory();
|
||||
$categoryDefault = $this->getCategoryDefault();
|
||||
|
||||
if (!is_null($category)) {
|
||||
$categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find();
|
||||
if (!is_null($category) ||!is_null($categoryDefault)) {
|
||||
|
||||
if (!is_null($category)) {
|
||||
$categories = CategoryQuery::create()->filterById($category, Criteria::IN)->find();
|
||||
}
|
||||
if (!is_null($categoryDefault)) {
|
||||
$categories = CategoryQuery::create()->filterById($categoryDefault, Criteria::IN)->find();
|
||||
}
|
||||
|
||||
$depth = $this->getDepth();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user