Fixed issue 118
This commit is contained in:
@@ -282,8 +282,12 @@ class Product extends BaseAction implements EventSubscriberInterface
|
|||||||
|
|
||||||
$product->setTemplateId($template_id)->save($con);
|
$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 !
|
// Store all the stuff !
|
||||||
$con->commit();
|
$con->commit();
|
||||||
|
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
|
|
||||||
$con->rollback();
|
$con->rollback();
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class ProductSaleElement extends BaseAction implements EventSubscriberInterface
|
|||||||
|
|
||||||
if ($salesElement == null) {
|
if ($salesElement == null) {
|
||||||
// Create a new default product sale element
|
// 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 {
|
} else {
|
||||||
// This (new) one is the default
|
// This (new) one is the default
|
||||||
$salesElement->setIsDefault(true)->save($con);
|
$salesElement->setIsDefault(true)->save($con);
|
||||||
|
|||||||
@@ -652,7 +652,7 @@ class ProductController extends AbstractCrudController
|
|||||||
|
|
||||||
$this->dispatch(
|
$this->dispatch(
|
||||||
TheliaEvents::PRODUCT_SET_TEMPLATE,
|
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;
|
namespace Thelia\Core\Event\Product;
|
||||||
|
|
||||||
use Thelia\Model\Product;
|
use Thelia\Model\Product;
|
||||||
|
|
||||||
class ProductSetTemplateEvent extends ProductEvent
|
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);
|
parent::__construct($product);
|
||||||
|
|
||||||
$this->template_id = $template_id;
|
$this->template_id = $template_id;
|
||||||
|
$this->currency_id = $currency_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplateId()
|
public function getTemplateId()
|
||||||
@@ -48,4 +49,15 @@ class ProductSetTemplateEvent extends ProductEvent
|
|||||||
return $this;
|
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;
|
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)) {
|
if (! empty($template)) {
|
||||||
@@ -175,6 +181,7 @@ class Attribute extends BaseI18nLoop implements PropelSearchLoopInterface
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
echo "s=".$search->toString();
|
||||||
|
|
||||||
return $search;
|
return $search;
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ class Feature extends BaseI18nLoop implements PropelSearchLoopInterface
|
|||||||
$this->useFeaturePosition = true;
|
$this->useFeaturePosition = true;
|
||||||
|
|
||||||
if (null !== $product) {
|
if (null !== $product) {
|
||||||
|
|
||||||
// Find all template assigned to the products.
|
// Find all template assigned to the products.
|
||||||
$products = ProductQuery::create()->findById($product);
|
$products = ProductQuery::create()->findById($product);
|
||||||
|
|
||||||
@@ -125,6 +126,12 @@ class Feature extends BaseI18nLoop implements PropelSearchLoopInterface
|
|||||||
if (! is_null($tpl_id)) $template[] = $tpl_id;
|
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)) {
|
if (! empty($template)) {
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ class Product extends BaseProduct
|
|||||||
->save($con)
|
->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 = new ProductPrice();
|
||||||
|
|
||||||
$product_price
|
$product_price
|
||||||
|
|||||||
Reference in New Issue
Block a user