/** * (non-PHPdoc) * @see CRUDPageAbstract::_getEndJs() */ protected function _getEndJs() { $manufactureArray = $supplierArray = $statuses = $productCategoryArray = array(); foreach (Manufacturer::getAll() as $os) { $manufactureArray[] = $os->getJson(); } foreach (Supplier::getAll() as $os) { $supplierArray[] = $os->getJson(); } foreach (ProductStatus::getAll() as $os) { $statuses[] = $os->getJson(); } foreach (ProductCategory::getAll() as $os) { $productCategoryArray[] = $os->getJson(); } $js = parent::_getEndJs(); if (($product = Product::get($this->Request['id'])) instanceof Product) { $js .= "\$('searchPanel').hide();"; $js .= "pageJs._singleProduct = true;"; } $js .= 'pageJs._loadManufactures(' . json_encode($manufactureArray) . ')'; $js .= '._loadSuppliers(' . json_encode($supplierArray) . ')'; $js .= '._loadCategories(' . json_encode($productCategoryArray) . ')'; $js .= '._loadProductStatuses(' . json_encode($statuses) . ')'; $js .= "._loadChosen()"; $js .= "._bindSearchKey()"; $js .= ".setCallbackId('priceMatching', '" . $this->priceMatchingBtn->getUniqueID() . "')"; $js .= ".setCallbackId('toggleActive', '" . $this->toggleActiveBtn->getUniqueID() . "')"; $js .= ".getResults(true, " . $this->pageSize . ");"; return $js; }
/** * Populate Product Template Model with data * @param Product Template object $model * @param int $counter */ public function populateModelData(&$model, $counter) { assert('$model instanceof ProductTemplate'); parent::populateModel($model); $productTemplateRandomData = self::getProductTemplatesRandomData(); $name = $productTemplateRandomData['names'][$counter]; $productCategoryName = self::getProductCategoryForTemplate($name); $allCats = ProductCategory::getAll(); foreach ($allCats as $category) { if ($category->name == $productCategoryName) { $categoryId = $category->id; } } $productCategory = ProductCategory::getById($categoryId); $model->name = $name; $model->productCategories->add($productCategory); $model->priceFrequency = 2; $model->cost->value = 200; $model->listPrice->value = 200; $model->sellPrice->value = 200; $model->status = ProductTemplate::STATUS_ACTIVE; $model->type = ProductTemplate::TYPE_PRODUCT; $sellPriceFormula = new SellPriceFormula(); $sellPriceFormula->type = SellPriceFormula::TYPE_EDITABLE; $model->sellPriceFormula = $sellPriceFormula; }
/** * (non-PHPdoc) * @see CRUDPageAbstract::_getEndJs() */ protected function _getEndJs() { $manufactureArray = $supplierArray = $statuses = $productCategoryArray = array(); foreach (Manufacturer::getAll() as $os) { $manufactureArray[] = $os->getJson(); } foreach (Supplier::getAll() as $os) { $supplierArray[] = $os->getJson(); } foreach (ProductStatus::getAll() as $os) { $statuses[] = $os->getJson(); } foreach (ProductCategory::getAll() as $os) { $productCategoryArray[] = $os->getJson(); } $js = parent::_getEndJs(); if (($product = Product::get($this->Request['id'])) instanceof Product) { $js .= "\$('searchPanel').hide();"; $js .= "pageJs._singleProduct = true;"; } $js .= 'pageJs.totalValueId = "total-found-value";'; $js .= 'pageJs.totalQtyId = "total-found-qty";'; $js .= 'pageJs._loadManufactures(' . json_encode($manufactureArray) . ')'; $js .= '._loadSuppliers(' . json_encode($supplierArray) . ')'; $js .= '._loadCategories(' . json_encode($productCategoryArray) . ')'; $js .= '._loadProductStatuses(' . json_encode($statuses) . ')'; $js .= "._loadChosen()"; $js .= "._bindSearchKey()"; $js .= "._bindNewRuleBtn()"; $js .= ".setCallbackId('priceMatching', '" . $this->priceMatchingBtn->getUniqueID() . "')"; $js .= ".setCallbackId('toggleActive', '" . $this->toggleActiveBtn->getUniqueID() . "')"; $js .= ".setCallbackId('toggleSellOnWeb', '" . $this->toggleSellOnWebBtn->getUniqueID() . "')"; $js .= ".setCallbackId('updatePrice', '" . $this->updatePriceBtn->getUniqueID() . "')"; $js .= ".setCallbackId('updateStockLevel', '" . $this->updateStockLevelBtn->getUniqueID() . "')"; $js .= ".setCallbackId('toggleIsKit', '" . $this->toggleIsKitBtn->getUniqueID() . "')"; $js .= ".setCallbackId('toggleManualFeed', '" . $this->toggleManualFeedBtn->getUniqueID() . "')"; $js .= ".setCallbackId('newRule', '" . $this->newRuleBtn->getUniqueID() . "')"; $js .= ".getResults(true, " . $this->pageSize . ");"; return $js; }
public function testGetAllWhenThereAreNone() { Yii::app()->user->userModel = User::getByUsername('super'); $productCategories = ProductCategory::getAll(); $this->assertEquals(0, count($productCategories)); }
public function testSuperUserDeleteAction() { $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); Yii::app()->user->userModel = $super; $productCategory = ProductCategoryTestHelper::createProductCategoryByName("My New Category"); //Delete a product template $this->setGetArray(array('id' => $productCategory->id)); $this->resetPostArray(); $productCategories = ProductCategory::getAll(); $this->assertEquals(14, count($productCategories)); $this->runControllerWithRedirectExceptionAndGetContent('productTemplates/category/delete'); $productCategories = ProductCategory::getAll(); $this->assertEquals(13, count($productCategories)); try { ProductCategory::getById($productCategory->id); $this->fail(); } catch (NotFoundException $e) { //success } }
protected function renderModalList($modalViewName, $pageTitle) { $rolesModalTreeView = new $modalViewName($this->getId(), $this->getModule()->getId(), $_GET['modalTransferInformation']['sourceModelId'], ProductCategory::getAll('name'), $_GET['modalTransferInformation']['sourceIdFieldId'], $_GET['modalTransferInformation']['sourceNameFieldId'], $_GET['modalTransferInformation']['modalId']); Yii::app()->getClientScript()->setToAjaxMode(); $view = new ModalView($this, $rolesModalTreeView); return $view->render(); }
public function syncAllProductCategory() { $pcArray = ProductCategory::getAll(true, null, DaoQuery::DEFAUTL_PAGE_SIZE, array('position' => 'ASC')); if (is_array($pcArray) && count($pcArray) > 0) { $soapClient = $this->_mySoapClient; foreach ($pcArray as $productCategory) { $categoryData = $this->_generateCategoryData($productCategory); if (($pcMageId = trim($productCategory->mageId)) === '' || $pcMageId === '0') { $parentId = 1; if (($pcParent = $productCategory->getParent()) instanceof ProductCategory) { $parentId = (int) $pcParent->getMageId(); } $newMageId = $soapClient->catalogCategoryCreate($this->_session, $parentId, $categoryData); $productCategory->setMageId($newMageId)->save(); } else { $updated = $soapClient->catalogCategoryUpdate($this->_session, $pcMageId, $categoryData); } } } return $this; }