/** * Create model * * @param array $data Data * * @return \XLite\Model\AEntity */ protected function createModel(array $data) { $model = parent::createModel($data); $inventory = new \XLite\Model\Inventory(); $inventory->setProduct($model); $model->setInventory($inventory); \XLite\Core\Database::getEM()->persist($model->getInventory()); return $model; }
/** * Get inventory * * @return \XLite\Model\Inventory */ public function getInventory() { if (null !== $this->inventory) { $inventory = $this->inventory; } else { $inventory = new \XLite\Model\Inventory(); $inventory->setProduct($this); } return $inventory; }
/** * doActionAdd * * @return void */ protected function doActionAdd() { $product = \XLite\Core\Database::getRepo('\\XLite\\Model\\Product')->insert($this->getPostedData()); if (isset($product)) { $this->updateSKU($product); $inventory = new \XLite\Model\Inventory(); $inventory->setProduct($product); // Create associations (categories and images) \XLite\Core\Database::getRepo('\\XLite\\Model\\Product')->update($product, $this->getCategoryProducts($product) + array('inventory' => $inventory) + $this->getClasses($product)); \XLite\Core\TopMessage::addInfo('New product has been added successfully'); // Add the ID of created product to the return URL $this->setReturnURL($this->buildURL('product', '', array('product_id' => $product->getProductId()))); } }