Finished product multiple categories attachment
This commit is contained in:
@@ -98,7 +98,8 @@ class Product extends BaseProduct
|
||||
->filterByDefaultCategory(true)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
var_dump($productCategory);
|
||||
exit;
|
||||
if ($productCategory == null || $productCategory->getCategoryId() != $defaultCategoryId) {
|
||||
|
||||
// Delete the old default category
|
||||
@@ -120,8 +121,13 @@ class Product extends BaseProduct
|
||||
* Create a new product, along with the default category ID
|
||||
*
|
||||
* @param int $defaultCategoryId the default category ID of this product
|
||||
* @param float $basePrice the product base price
|
||||
* @param int $priceCurrencyId the price currency Id
|
||||
* @param int $taxRuleId the product tax rule ID
|
||||
* @param float $baseWeight base weight in Kg
|
||||
*/
|
||||
public function create($defaultCategoryId) {
|
||||
|
||||
public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight) {
|
||||
|
||||
$con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
|
||||
|
||||
@@ -139,6 +145,8 @@ class Product extends BaseProduct
|
||||
// Set the position
|
||||
$this->setPosition($this->getNextPosition())->save($con);
|
||||
|
||||
$this->setTaxRuleId($taxRuleId);
|
||||
|
||||
// Create an empty product sale element
|
||||
$sale_elements = new ProductSaleElements();
|
||||
|
||||
@@ -147,7 +155,8 @@ class Product extends BaseProduct
|
||||
->setRef($this->getRef())
|
||||
->setPromo(0)
|
||||
->setNewness(0)
|
||||
->setWeight(0)
|
||||
->setWeight($baseWeight)
|
||||
->setIsDefault(true)
|
||||
->save($con)
|
||||
;
|
||||
|
||||
@@ -156,9 +165,9 @@ class Product extends BaseProduct
|
||||
|
||||
$product_price
|
||||
->setProductSaleElements($sale_elements)
|
||||
->setPromoPrice(0)
|
||||
->setPrice(0)
|
||||
->setCurrency(CurrencyQuery::create()->findOneByByDefault(true))
|
||||
->setPromoPrice($basePrice)
|
||||
->setPrice($basePrice)
|
||||
->setCurrencyId($priceCurrencyId)
|
||||
->save($con)
|
||||
;
|
||||
|
||||
|
||||
@@ -11,11 +11,22 @@ class ProductAssociatedContent extends BaseProductAssociatedContent {
|
||||
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
|
||||
/**
|
||||
* Calculate next position relative to our product
|
||||
*/
|
||||
protected function addCriteriaToPositionQuery($query) {
|
||||
$query->filterByProductId($this->getProductId());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this));
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user