Finished product multiple categories attachment

This commit is contained in:
franck
2013-09-22 22:14:39 +02:00
parent 72a2cdfd75
commit 22f3f49f79
37 changed files with 1049 additions and 498 deletions

View 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\Product;
class ProductAddCategoryEvent extends ProductEvent
{
protected $category_id;
public function __construct(Product $product, $category_id)
{
parent::__construct($product);
$this->category_id = $category_id;
}
public function getCategoryId()
{
return $this->category_id;
}
public function setCategoryId($category_id)
{
$this->category_id = $category_id;
}
}

View File

@@ -31,6 +31,11 @@ class ProductCreateEvent extends ProductEvent
protected $default_category;
protected $visible;
protected $basePrice;
protected $baseWeight;
protected $taxRuleId;
protected $currencyId;
public function getRef()
{
return $this->ref;
@@ -85,4 +90,48 @@ class ProductCreateEvent extends ProductEvent
$this->visible = $visible;
return $this;
}
public function getBasePrice()
{
return $this->basePrice;
}
public function setBasePrice($basePrice)
{
$this->basePrice = $basePrice;
return $this;
}
public function getBaseWeight()
{
return $this->baseWeight;
}
public function setBaseWeight($baseWeight)
{
$this->baseWeight = $baseWeight;
return $this;
}
public function getTaxRuleId()
{
return $this->taxRuleId;
}
public function setTaxRuleId($taxRuleId)
{
$this->taxRuleId = $taxRuleId;
return $this;
}
public function getCurrencyId()
{
return $this->currencyId;
}
public function setCurrencyId($currencyId)
{
$this->currencyId = $currencyId;
return $this;
}
}

View File

@@ -0,0 +1,50 @@
<?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\Product;
class ProductDeleteCategoryEvent extends ProductEvent
{
protected $category_id;
public function __construct(Product $product, $category_id)
{
parent::__construct($product);
$this->category_id = $category_id;
}
public function getCategoryId()
{
return $this->category_id;
}
public function setCategoryId($category_id)
{
$this->category_id = $category_id;
return $this;
}
}

View File

@@ -184,17 +184,21 @@ final class TheliaEvents
const PRODUCT_TOGGLE_VISIBILITY = "action.toggleProductVisibility";
const PRODUCT_UPDATE_POSITION = "action.updateProductPosition";
const PRODUCT_ADD_CONTENT = "action.productAddContent";
const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent";
const PRODUCT_ADD_CONTENT = "action.productAddContent";
const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent";
const PRODUCT_UPDATE_CONTENT_POSITION = "action.updateProductContentPosition";
const PRODUCT_SET_TEMPLATE = "action.productSetTemplate";
const PRODUCT_ADD_ACCESSORY = "action.productAddAccessory";
const PRODUCT_REMOVE_ACCESSORY = "action.productRemoveAccessory";
const PRODUCT_UPDATE_ACCESSORY_POSITION = "action.updateProductPosition";
const PRODUCT_ADD_ACCESSORY = "action.productAddProductAccessory";
const PRODUCT_REMOVE_ACCESSORY = "action.productRemoveProductAccessory";
const PRODUCT_UPDATE_ACCESSORY_POSITION = "action.updateProductAccessoryPosition";
const PRODUCT_FEATURE_UPDATE_VALUE = "action.after_updateProductFeatureValue";
const PRODUCT_FEATURE_DELETE_VALUE = "action.after_deleteProductFeatureValue";
const PRODUCT_FEATURE_UPDATE_VALUE = "action.updateProductFeatureValue";
const PRODUCT_FEATURE_DELETE_VALUE = "action.deleteProductFeatureValue";
const PRODUCT_ADD_CATEGORY = "action.addProductCategory";
const PRODUCT_REMOVE_CATEGORY = "action.deleteProductCategory";
const BEFORE_CREATEPRODUCT = "action.before_createproduct";
const AFTER_CREATEPRODUCT = "action.after_createproduct";

View File

@@ -74,6 +74,7 @@ class Accessory extends Product
$search = AccessoryQuery::create();
$product = $this->getProduct();
$search->filterByProductId($product, Criteria::IN);
$order = $this->getOrder();
@@ -93,10 +94,16 @@ class Accessory extends Product
$accessories = $this->search($search);
$accessoryIdList = array(0);
$accessoryPosition = array();
$accessoryPosition = $accessoryId = array();
foreach ($accessories as $accessory) {
array_push($accessoryIdList, $accessory->getAccessory());
$accessoryPosition[$accessory->getAccessory()] = $accessory->getPosition();
$accessoryProductId = $accessory->getAccessory();
array_push($accessoryIdList, $accessoryProductId);
$accessoryPosition[$accessoryProductId] = $accessory->getPosition();
$accessoryId[$accessoryProductId] = $accessory->getId();
}
$receivedIdList = $this->getId();
@@ -111,12 +118,15 @@ class Accessory extends Product
$loopResult = parent::exec($pagination);
foreach($loopResult as $loopResultRow) {
$accessoryProductId = $loopResultRow->get('ID');
$loopResultRow
->set("POSITION" , $accessoryPosition[$loopResultRow->get('ID')])
;
->set("ID" , $accessoryId[$accessoryProductId])
->set("POSITION", $accessoryPosition[$accessoryProductId])
;
}
return $loopResult;
}
}

View File

@@ -135,8 +135,17 @@ class AssociatedContent extends Content
$associatedContents = $this->search($search);
$associatedContentIdList = array(0);
$contentIdList = array(0);
$contentPosition = $contentId = array();
foreach ($associatedContents as $associatedContent) {
array_push($associatedContentIdList, $associatedContent->getContentId());
$associatedContentId = $associatedContent->getContentId();
array_push($associatedContentIdList, $associatedContentId);
$contentPosition[$associatedContentId] = $associatedContent->getPosition();
$contentId[$associatedContentId] = $associatedContent->getId();
}
$receivedIdList = $this->getId();
@@ -148,7 +157,18 @@ class AssociatedContent extends Content
$this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $associatedContentIdList)) );
}
return parent::exec($pagination);
}
$loopResult = parent::exec($pagination);
foreach($loopResult as $loopResultRow) {
$relatedContentId = $loopResultRow->get('ID');
$loopResultRow
->set("ID" , $contentId[$relatedContentId])
->set("POSITION", $contentPosition[$relatedContentId])
;
}
return $loopResult;
}
}

View File

@@ -121,12 +121,15 @@ class Attribute extends BaseI18nLoop
// Create template array
if ($template == null) $template = array();
foreach($products as $product)
$template[] = $product->getTemplateId();
foreach($products as $product) {
$tpl_id = $product->getTemplateId();
if (! is_null($tpl_id)) $template[] = $tpl_id;
}
}
}
if (null !== $template) {
if (! empty($template)) {
// Join with feature_template table to get position
$search

View File

@@ -35,6 +35,7 @@ use Thelia\Model\CategoryQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
use Thelia\Model\ProductQuery;
/**
*
@@ -73,6 +74,8 @@ class Category extends BaseI18nLoop
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
Argument::createIntTypeArgument('parent'),
Argument::createIntTypeArgument('product'),
Argument::createIntTypeArgument('exclude_product'),
Argument::createBooleanTypeArgument('current'),
Argument::createBooleanTypeArgument('not_empty', 0),
Argument::createBooleanOrBothTypeArgument('visible', 1),
@@ -128,6 +131,22 @@ class Category extends BaseI18nLoop
if ($this->getVisible() != BooleanOrBothType::ANY)
$search->filterByVisible($this->getVisible() ? 1 : 0);
$product = $this->getProduct();
if ($product != null) {
$obj = ProductQuery::create()->findPk($product);
if ($obj != null) $search->filterByProduct($obj, Criteria::IN);
}
$exclude_product = $this->getExclude_product();
if ($exclude_product != null) {
$obj = ProductQuery::create()->findPk($exclude_product);
if ($obj != null) $search->filterByProduct($obj, Criteria::NOT_IN);
}
$orders = $this->getOrder();
foreach ($orders as $order) {

View File

@@ -124,12 +124,15 @@ class Feature extends BaseI18nLoop
// Create template array
if ($template == null) $template = array();
foreach($products as $product)
$template[] = $product->getTemplateId();
foreach($products as $product) {
$tpl_id = $product->getTemplateId();
if (! is_null($tpl_id)) $template[] = $tpl_id;
}
}
}
if (null !== $template) {
if (! empty($template)) {
// Join with feature_template table to get position
$search