Merge branch 'master' of https://github.com/thelia/thelia into coupon

* 'master' of https://github.com/thelia/thelia:
  update changelog
  delete product on category removal. delete only when it's the default category. Fix issue #151
  delete all sub categories on category removal, fix issue #150
  session parameter is needed on TaxEngine::getInstance method
  put at the beginning of changelog file the new features
  start a new section in changelog file
  uncomment needed loop for parent folder
  add missing value in folder modification form
  uncomment needed return statement
  Use $parent instead of $folder_id in folders admin template
This commit is contained in:
gmorel
2014-01-05 20:20:11 +01:00
3 changed files with 30 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
#2.0.0-beta3
- Coupon effect inputs are now more customisable (input text, select, ajax, etc.. are usable) and unlimited amount of input for coupon effect are now possible too
- when a category is deleted, all subcategories are deleted
- delete products when categories are removed. Works only when the category is the default one for this product
#2.0.0-beta2

View File

@@ -40,7 +40,7 @@ class TaxCreationForm extends BaseForm
protected function buildForm($change_mode = false)
{
$types = TaxEngine::getInstance()->getTaxTypeList();
$types = TaxEngine::getInstance($this->getRequest()->getSession())->getTaxTypeList();
$typeList = array();
$requirementList = array();
foreach ($types as $type) {

View File

@@ -5,6 +5,7 @@ namespace Thelia\Model;
use Thelia\Core\Event\Category\CategoryEvent;
use Thelia\Model\Base\Category as BaseCategory;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Model\ProductCategoryQuery;
use Thelia\Tools\URL;
use Thelia\Core\Event\TheliaEvents;
use Propel\Runtime\Connection\ConnectionInterface;
@@ -62,6 +63,22 @@ class Category extends BaseCategory
$query->filterByParent($this->getParent());
}
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();
$product->delete($con);
}
}
}
/**
* {@inheritDoc}
*/
@@ -111,6 +128,7 @@ class Category extends BaseCategory
"parent" => $this->getParent(),
)
);
$this->deleteProducts($con);
return true;
}
@@ -121,6 +139,15 @@ class Category extends BaseCategory
{
$this->markRewritenUrlObsolete();
//delete all subcategories
$subCategories = CategoryQuery::findAllChild($this->getId());
foreach($subCategories as $category) {
$category->setDispatcher($this->getDispatcher());
$category->delete();
}
$this->dispatchEvent(TheliaEvents::AFTER_DELETECATEGORY, new CategoryEvent($this));
}
}