Fixed issue 118
This commit is contained in:
@@ -282,8 +282,12 @@ class Product extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
$product->setTemplateId($template_id)->save($con);
|
||||
|
||||
// Create a new default product sale element
|
||||
$product->createProductSaleElement($con, 0, 0, 0, $event->getCurrencyId(), true);
|
||||
|
||||
// Store all the stuff !
|
||||
$con->commit();
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
$con->rollback();
|
||||
|
||||
@@ -67,7 +67,7 @@ class ProductSaleElement extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
if ($salesElement == null) {
|
||||
// Create a new default product sale element
|
||||
$salesElement = $event->getProduct()->createDefaultProductSaleElement($con, 0, 0, 0, $event->getCurrencyId(), true);
|
||||
$salesElement = $event->getProduct()->createProductSaleElement($con, 0, 0, 0, $event->getCurrencyId(), true);
|
||||
} else {
|
||||
// This (new) one is the default
|
||||
$salesElement->setIsDefault(true)->save($con);
|
||||
|
||||
@@ -652,7 +652,7 @@ class ProductController extends AbstractCrudController
|
||||
|
||||
$this->dispatch(
|
||||
TheliaEvents::PRODUCT_SET_TEMPLATE,
|
||||
new ProductSetTemplateEvent($product, $template_id)
|
||||
new ProductSetTemplateEvent($product, $template_id, $this->getCurrentEditionCurrency()->getId())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,18 +22,19 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Product;
|
||||
|
||||
use Thelia\Model\Product;
|
||||
|
||||
class ProductSetTemplateEvent extends ProductEvent
|
||||
{
|
||||
public $template_id = null;
|
||||
protected $template_id = null;
|
||||
protected $currency_id = 0;
|
||||
|
||||
public function __construct(Product $product = null, $template_id)
|
||||
public function __construct(Product $product = null, $template_id, $currency_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
|
||||
$this->template_id = $template_id;
|
||||
$this->currency_id = $currency_id;
|
||||
}
|
||||
|
||||
public function getTemplateId()
|
||||
@@ -48,4 +49,15 @@ class ProductSetTemplateEvent extends ProductEvent
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
public function getCurrencyId()
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
public function setCurrencyId($currency_id)
|
||||
{
|
||||
$this->currency_id = $currency_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -120,6 +120,12 @@ class Attribute extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
if (! is_null($tpl_id)) $template[] = $tpl_id;
|
||||
}
|
||||
}
|
||||
|
||||
// franck@cqfdev.fr - 05/12/2013 : if the given product has no template
|
||||
// or if the product cannot be found, do not return anything.
|
||||
if (empty($template)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($template)) {
|
||||
@@ -175,6 +181,7 @@ class Attribute extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
break;
|
||||
}
|
||||
}
|
||||
echo "s=".$search->toString();
|
||||
|
||||
return $search;
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ class Feature extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
$this->useFeaturePosition = true;
|
||||
|
||||
if (null !== $product) {
|
||||
|
||||
// Find all template assigned to the products.
|
||||
$products = ProductQuery::create()->findById($product);
|
||||
|
||||
@@ -125,6 +126,12 @@ class Feature extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
if (! is_null($tpl_id)) $template[] = $tpl_id;
|
||||
}
|
||||
}
|
||||
|
||||
// franck@cqfdev.fr - 05/12/2013 : if the given product has no template
|
||||
// or if the product cannot be found, do not return anything.
|
||||
if (empty($template)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($template)) {
|
||||
|
||||
@@ -202,7 +202,7 @@ class Product extends BaseProduct
|
||||
->save($con)
|
||||
;
|
||||
|
||||
// Create an empty product price in the default currency
|
||||
// Create an empty product price in the provided currency
|
||||
$product_price = new ProductPrice();
|
||||
|
||||
$product_price
|
||||
|
||||
Reference in New Issue
Block a user