Added brand storage in product table
This commit is contained in:
@@ -99,6 +99,7 @@ class Product extends BaseAction implements EventSubscriberInterface
|
||||
->setChapo($event->getChapo())
|
||||
->setPostscriptum($event->getPostscriptum())
|
||||
->setVisible($event->getVisible() ? 1 : 0)
|
||||
->setBrandId($event->getBrandId() <= 0 ? null : $event->getBrandId())
|
||||
|
||||
->save()
|
||||
;
|
||||
|
||||
@@ -164,6 +164,7 @@ class ProductController extends AbstractSeoCrudController
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
->setVisible($formData['visible'])
|
||||
->setDefaultCategory($formData['default_category'])
|
||||
->setBrandId($formData['brand_id'])
|
||||
;
|
||||
|
||||
// Create and dispatch the change event
|
||||
@@ -213,6 +214,10 @@ class ProductController extends AbstractSeoCrudController
|
||||
$array[$key][] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product $object
|
||||
* @return ProductModificationForm
|
||||
*/
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
// Find product's sale elements
|
||||
@@ -320,7 +325,8 @@ class ProductController extends AbstractSeoCrudController
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'default_category' => $object->getDefaultCategoryId()
|
||||
'default_category' => $object->getDefaultCategoryId(),
|
||||
'brand_id' => $object->getBrandId()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
|
||||
@@ -19,6 +19,8 @@ class ProductUpdateEvent extends ProductCreateEvent
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
protected $brand_id;
|
||||
|
||||
|
||||
public function __construct($product_id)
|
||||
{
|
||||
@@ -72,4 +74,22 @@ class ProductUpdateEvent extends ProductCreateEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $brand_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setBrandId($brand_id)
|
||||
{
|
||||
$this->brand_id = $brand_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBrandId()
|
||||
{
|
||||
return $this->brand_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ use Thelia\Core\Event\Product\ProductSetTemplateEvent;
|
||||
use Thelia\Core\Event\Product\ProductToggleVisibilityEvent;
|
||||
use Thelia\Core\Event\Product\ProductUpdateEvent;
|
||||
use Thelia\Model\AccessoryQuery;
|
||||
use Thelia\Model\BrandQuery;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
@@ -115,6 +116,7 @@ class ProductTest extends TestCaseWithURLToolSetup
|
||||
{
|
||||
$event = new ProductUpdateEvent($product->getId());
|
||||
$defaultCategory = CategoryQuery::create()->select('id')->addAscendingOrderByColumn('RAND()')->findOne();
|
||||
$brandId = BrandQuery::create()->findOne()->getId();
|
||||
$event
|
||||
->setLocale('fr_FR')
|
||||
->setTitle('test MAJ titre en français')
|
||||
@@ -123,6 +125,7 @@ class ProductTest extends TestCaseWithURLToolSetup
|
||||
->setPostscriptum('test postscriptum fr')
|
||||
->setVisible(1)
|
||||
->setDefaultCategory($defaultCategory)
|
||||
->setBrandId($brandId)
|
||||
->setDispatcher($this->getDispatcher());
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user