Inheritance: extends BaseModel
 public function testZeroPriceWithVariations()
 {
     Config::inst()->update('ProductCategory', 'must_have_price', true);
     $products = $this->electronics->ProductsShowable();
     $this->assertEquals(0, $products->count(), 'No product should be returned as there\'s no price set');
     // Create a variation for HDTV
     ProductVariation::create(array('InternalItemID' => '50-Inch', 'Price' => 1200, 'ProductID' => $this->hdtv->ID))->write();
     $products = $this->electronics->ProductsShowable();
     $this->assertDOSEquals(array(array('URLSegment' => 'hdtv')), $products, 'HDTV has a priced extension and should now show up in the list of products');
 }
 public function executeProductLink(sfWebRequest $request)
 {
     if ($request->hasParameter("categoryid") && $request->hasParameter("productid")) {
         $prodcat = new ProductCategory();
         $prodcat->setProductId($request->getParameter("productid"));
         $prodcat->setCategoryId($request->getParameter("categoryid"));
         $prodcat->save();
         cart::update_node($request->getParameter("categoryid"));
         return true;
     }
 }
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $allCats = DataObject::get('ProductCategory');
     if (!$allCats->count()) {
         $cat = new ProductCategory();
         $cat->Title = 'Default';
         $cat->Code = 'DEFAULT';
         $cat->write();
     }
 }
 public static function createProductCategory($id = '')
 {
     $time = mt_rand();
     $name = 'SugarProductCategory';
     $product = new ProductCategory();
     $product->name = $name . $time;
     if (!empty($id)) {
         $product->new_with_id = true;
         $product->id = $id;
     }
     $product->save();
     self::$_createdProductCategories[] = $product;
     return $product;
 }
 public static function createProductCategoryByName($name, $parentCategory = null)
 {
     $productCategory = new ProductCategory();
     $productCategory->name = $name;
     $productCatalog = new ProductCatalog();
     $productCatalog->name = ProductCatalog::DEFAULT_NAME;
     $productCatalog->save();
     $productCategory->productCatalogs->add($productCatalog);
     $saved = $productCategory->save();
     if ($parentCategory != null) {
         $productCategory->productCategories->add($parentCategory);
     }
     assert('$saved');
     return $productCategory;
 }
 public function actions()
 {
     $formSettings = array('redirect' => $this->createUrl('admin'), 'forms' => array('id' => 'mainForm', 'varName' => 'productCategory', 'models' => 'ProductCategory', 'onAfterSave' => function ($event) {
         $model = $event->params['model'];
         if ($model->location != 'nochange') {
             $decode = CJSON::decode($_POST['ProductCategory']['location']);
             $to = ProductCategory::model()->findByPk((int) $decode['to']);
             $action = $decode['action'];
             switch ($action) {
                 case 'child':
                     $model->moveAsLast($to);
                     break;
                 case 'before':
                     if ($to->isRoot()) {
                         $model->moveAsRoot();
                     } else {
                         $model->moveBefore($to);
                     }
                     break;
                 case 'after':
                     if ($to->isRoot()) {
                         $model->moveAsRoot();
                     } else {
                         $model->moveAfter($to);
                     }
                     break;
             }
         }
     }));
     return array('create' => array('class' => 'application.components.actions.Create', 'formSettings' => $formSettings), 'update' => array('class' => 'application.components.actions.Update', 'formSettings' => $formSettings), 'delete' => array('class' => 'application.components.actions.Delete', 'modelClass' => 'ProductCategory'), 'admin' => array('class' => 'application.components.actions.Admin', 'modelClass' => 'ProductCategory'));
 }
Exemple #7
0
 public function __construct($controller, $name)
 {
     $product = new Product();
     $title = new TextField('Title', _t('Product.PAGETITLE', 'Product Title'));
     $urlSegment = new TextField('URLSegment', 'URL Segment');
     $menuTitle = new TextField('MenuTitle', 'Navigation Title');
     $sku = TextField::create('InternalItemID', _t('Product.CODE', 'Product Code/SKU'), '', 30);
     $categories = DropdownField::create('ParentID', _t("Product.CATEGORY", "Category"), $product->categoryoptions())->setDescription(_t("Product.CATEGORYDESCRIPTION", "This is the parent page or default category."));
     $otherCategories = ListBoxField::create('ProductCategories', _t("Product.ADDITIONALCATEGORIES", "Additional Categories"), ProductCategory::get()->filter("ID:not", $product->getAncestors()->map('ID', 'ID'))->map('ID', 'NestedTitle')->toArray())->setMultiple(true);
     $model = TextField::create('Model', _t('Product.MODEL', 'Model'), '', 30);
     $featured = CheckboxField::create('Featured', _t('Product.FEATURED', 'Featured Product'));
     $allow_purchase = CheckboxField::create('AllowPurchase', _t('Product.ALLOWPURCHASE', 'Allow product to be purchased'), 1, 'Content');
     $price = TextField::create('BasePrice', _t('Product.PRICE', 'Price'))->setDescription(_t('Product.PRICEDESC', "Base price to sell this product at."))->setMaxLength(12);
     $image = UploadField::create('Image', _t('Product.IMAGE', 'Product Image'));
     $content = new HtmlEditorField('Content', 'Content');
     $fields = new FieldList();
     $fields->add($title);
     //$fields->add($urlSegment);
     //$fields->add($menuTitle);
     //$fields->add($sku);
     $fields->add($categories);
     //$fields->add($otherCategories);
     $fields->add($model);
     $fields->add($featured);
     $fields->add($allow_purchase);
     $fields->add($price);
     $fields->add($image);
     $fields->add($content);
     //$fields = $product->getFrontEndFields();
     $actions = new FieldList(new FormAction('submit', _t("ChefProductForm.ADDPRODUCT", 'Add product')));
     $requiredFields = new RequiredFields(array('Title', 'Model', 'Price'));
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
 }
Exemple #8
0
 public function testLoad()
 {
     $this->assertEquals(2, Group::getCount());
     $this->assertEquals(0, Role::getCount());
     $this->assertEquals(0, Account::getCount());
     $this->assertEquals(0, Contact::getCount());
     $this->assertEquals(0, Opportunity::getCount());
     $this->assertEquals(0, Meeting::getCount());
     $this->assertEquals(0, Note::getCount());
     $this->assertEquals(0, Task::getCount());
     $this->assertEquals(1, User::getCount());
     $this->assertEquals(0, ProductCatalog::getCount());
     $this->assertEquals(0, ProductCategory::getCount());
     $this->assertEquals(0, ProductTemplate::getCount());
     $this->assertEquals(0, Product::getCount());
     $messageLogger = new MessageLogger();
     DemoDataUtil::unsetLoadedModules();
     DemoDataUtil::load($messageLogger, 3);
     $this->assertEquals(8, Group::getCount());
     $this->assertEquals(3, Role::getCount());
     $this->assertEquals(3, Account::getCount());
     $this->assertEquals(16, Contact::getCount());
     $this->assertEquals(6, Opportunity::getCount());
     $this->assertEquals(18, Meeting::getCount());
     $this->assertEquals(12, Note::getCount());
     $this->assertEquals(9, Task::getCount());
     $this->assertEquals(10, User::getCount());
     $this->assertEquals(1, ProductCatalog::getCount());
     $this->assertEquals(6, ProductCategory::getCount());
     $this->assertEquals(32, ProductTemplate::getCount());
     $this->assertEquals(59, Product::getCount());
 }
 /**
  * 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;
 }
Exemple #10
0
 public function screen()
 {
     $status = 'available';
     if (!is_dir($this->theme_path)) {
         $status = 'directory';
     } else {
         if (!is_writable($this->theme_path)) {
             $status = 'permissions';
         } else {
             $builtin = array_filter(scandir($this->template_path), 'filter_dotfiles');
             $theme = array_filter(scandir($this->theme_path), 'filter_dotfiles');
             if (empty($theme)) {
                 $status = 'ready';
             } elseif (array_diff($builtin, $theme)) {
                 $status = 'incomplete';
             }
         }
     }
     $category_views = array('grid' => Shopp::__('Grid'), 'list' => Shopp::__('List'));
     $row_products = array(2, 3, 4, 5, 6, 7);
     $productOrderOptions = ProductCategory::sortoptions();
     $productOrderOptions['custom'] = Shopp::__('Custom');
     $orderOptions = array('ASC' => Shopp::__('Order'), 'DESC' => Shopp::__('Reverse Order'), 'RAND' => Shopp::__('Shuffle'));
     $orderBy = array('sortorder' => Shopp::__('Custom arrangement'), 'created' => Shopp::__('Upload date'));
     include $this->ui('presentation.php');
 }
 public function getDefaultSearchContext()
 {
     $context = parent::getDefaultSearchContext();
     $fields = $context->getFields();
     $fields->push(CheckboxField::create("HasBeenUsed"));
     //add date range filtering
     $fields->push(ToggleCompositeField::create("StartDate", "Start Date", array(DateField::create("q[StartDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[StartDateTo]", "To")->setConfig('showcalendar', true))));
     $fields->push(ToggleCompositeField::create("EndDate", "End Date", array(DateField::create("q[EndDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[EndDateTo]", "To")->setConfig('showcalendar', true))));
     //must be enabled in config, because some sites may have many products = slow load time, or memory maxes out
     //future solution is using an ajaxified field
     if (self::config()->filter_by_product) {
         $fields->push(ListboxField::create("Products", "Products", Product::get()->map()->toArray())->setMultiple(true));
     }
     if (self::config()->filter_by_category) {
         $fields->push(ListboxField::create("Categories", "Categories", ProductCategory::get()->map()->toArray())->setMultiple(true));
     }
     if ($field = $fields->fieldByName("Code")) {
         $field->setDescription("This can be a partial match.");
     }
     //get the array, to maniplulate name, and fullname seperately
     $filters = $context->getFilters();
     $filters['StartDateFrom'] = GreaterThanOrEqualFilter::create('StartDate');
     $filters['StartDateTo'] = LessThanOrEqualFilter::create('StartDate');
     $filters['EndDateFrom'] = GreaterThanOrEqualFilter::create('EndDate');
     $filters['EndDateTo'] = LessThanOrEqualFilter::create('EndDate');
     $context->setFilters($filters);
     return $context;
 }
 /**
  * getListItems - Phương thức dùng để lấy dữ liệu
  */
 public function getListItems($category_id = null)
 {
     Yii::import('application.modules.products.models.ProductItem');
     $model = new ProductItem('search');
     $model->unsetAttributes();
     $criteria = new CDbCriteria();
     $criteria->order = 'created DESC';
     if ($category_id) {
         Yii::import('application.modules.products.models.ProductCategory');
         $categories = ProductCategory::model()->findByPk($category_id);
         if (!$categories) {
             return null;
         }
         $this->__category = $categories;
         $descendants = $categories->descendants()->findAll('is_active = 1');
         $arrCat = array($category_id);
         foreach ($descendants as $cat) {
             $arrCat[] = $cat->id;
         }
         $criteria->with = array('categoryitem');
         $criteria->together = true;
         foreach ($arrCat as $cat) {
             $criteria->compare('categoryitem.category_id', $cat, false, 'OR');
         }
     }
     $criteria->compare('status', 1);
     $search = new CActiveDataProvider($model, array('criteria' => $criteria, 'pagination' => array('pageSize' => Yii::app()->getModule('products')->entriesShow)));
     $data = $search->getData();
     $this->__pagination = $search->pagination;
     return $data;
 }
 /**
  * Resolve the product categories from prost
  * @param ProductTemplate $productTemplate
  * @param array $postData
  * @return array
  */
 public static function resolveProductTemplateHasManyProductCategoriesFromPost(ProductTemplate $productTemplate, $postData)
 {
     $newCategory = array();
     if (isset($postData['categoryIds']) && strlen($postData['categoryIds']) > 0) {
         $categoryIds = explode(",", $postData['categoryIds']);
         // Not Coding Standard
         foreach ($categoryIds as $categoryId) {
             $newCategory[$categoryId] = ProductCategory::getById((int) $categoryId);
         }
         if ($productTemplate->productCategories->count() > 0) {
             $categoriesToRemove = array();
             foreach ($productTemplate->productCategories as $index => $existingCategory) {
                 $categoriesToRemove[] = $existingCategory;
             }
             foreach ($categoriesToRemove as $categoryToRemove) {
                 $productTemplate->productCategories->remove($categoryToRemove);
             }
         }
         //Now add missing categories
         foreach ($newCategory as $category) {
             $productTemplate->productCategories->add($category);
         }
     } else {
         //remove all categories
         $productTemplate->productCategories->removeAll();
     }
     return $newCategory;
 }
Exemple #14
0
 public function run()
 {
     $categoriesTree = ProductCategory::model()->getTree();
     $currentCategory = Yii::app()->daShop->currentIdCategory !== null ? $categoriesTree->getById(Yii::app()->daShop->currentIdCategory) : null;
     $tree = array('items' => $this->buildTree($categoriesTree, $currentCategory));
     $this->render('categoryWidget', compact('tree'));
 }
 public function addmodels($id)
 {
     if ($this->isAdminRequest()) {
         //$id = $_POST['id'];
         // print_r($_POST);
         $rules = array('models' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         // process the login
         if ($validator->fails()) {
             return Redirect::to('admin/products/' . $id . '/models')->withErrors($validator)->with('productcategory', ProductCategory::find($id))->with('models', Products::where('product_category_id', '=', $id)->get())->withInput(Input::all());
         } else {
             $models = Input::get('models');
             $models_arr = explode(",", $models);
             foreach ($models_arr as $model) {
                 $product_model = new Products();
                 $product_model->model_id = $model;
                 $product_model->product_category_id = $id;
                 $product_model->save();
             }
             // // redirect
             Session::flash('message', 'Successfully added models.');
             return Redirect::to('admin/products/' . $id . '/models');
         }
         //$import = importmodels('boo');
         //
         // $productcategory = ProductCategory::find($id);
         // $models = Products::where('product_category_id','=',$id)->get();
         // return View::make('admin.products.models')
         //     ->with('productcategory',$productcategory)
         //     ->with('models',$models);
         // }
     }
 }
 public function handleRequest(SS_HTTPRequest $request, DataModel $model)
 {
     $this->pushCurrent();
     $this->urlParams = $request->allParams();
     $this->request = $request;
     $this->response = new SS_HTTPResponse();
     $this->setDataModel($model);
     $urlsegment = $request->param('URLSegment');
     $this->extend('onBeforeInit');
     $this->init();
     $this->extend('onAfterInit');
     // First check products against URL segment
     if ($product = Product::get()->filter(array('URLSegment' => $urlsegment, 'Disabled' => 0))->first()) {
         $controller = Catalogue_Controller::create($product);
     } elseif ($category = ProductCategory::get()->filter('URLSegment', $urlsegment)->first()) {
         $controller = Catalogue_Controller::create($category);
     } else {
         // If CMS is installed
         if (class_exists('ModelAsController')) {
             $controller = ModelAsController::create();
         }
     }
     $result = $controller->handleRequest($request, $model);
     $this->popCurrent();
     return $result;
 }
 /**
  * (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;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     Product::create(['name' => 'Test Product', 'slug' => 'test-product', 'price' => 100, 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent rhoncus, turpis ac imperdiet dapibus, leo orci gravida neque, in malesuada elit libero eu sapien. Mauris sed sapien id sapien bibendum luctus et eu massa. Nulla egestas interdum magna non dignissim. Sed a laoreet purus, non rutrum augue. Proin laoreet eros nec elit mattis euismod. Aliquam facilisis, lacus blandit iaculis accumsan, leo quam sagittis nisi, non dapibus arcu libero efficitur turpis. In fringilla est nec sapien tempus suscipit. Suspendisse eget justo risus.']);
     Product::create(['name' => 'Uncategorized Product', 'slug' => 'uncategorized-product', 'price' => 200, 'description' => 'This product has no category.']);
     Category::create(['name' => 'Test Category', 'slug' => 'test-category']);
     ProductCategory::create(['product_id' => 1, 'category_id' => 1]);
 }
 public function loadModel($id)
 {
     $model = ProductCategory::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
function create_category($parent_id)
{
    global $sugar_demodata;
    $last_name_array = $sugar_demodata['last_name_array'];
    $last_name_count = count($sugar_demodata['last_name_array']);
    $last_name_max = $last_name_count - 1;
    $category = new ProductCategory();
    $category->name = $last_name_array[mt_rand(0, $last_name_max)] . $sugar_demodata['category_ext_name'];
    $category->parent_id = $parent_id;
    $key = array_rand($sugar_demodata['users']);
    $category->assigned_user_id = $sugar_demodata['users'][$key]['id'];
    $category->save();
    $cat_id = $category->id;
    unset($category);
    return $cat_id;
    //end function create_category
}
 public function getContinueLink()
 {
     $maincategory = ProductCategory::get()->sort(array("ParentID" => "ASC", "ID" => "ASC"))->first();
     if ($maincategory) {
         return $maincategory->Link();
     }
     return Director::baseURL();
 }
Exemple #22
0
function updateProduct($pro, $fileName, $line)
{
    $clientScript = CatelogConnector::getConnector(B2BConnector::CONNECTOR_TYPE_CATELOG, getWSDL(), 'B2BUser', 'B2BUser');
    try {
        $transStarted = false;
        try {
            Dao::beginTransaction();
        } catch (Exception $e) {
            $transStarted = true;
        }
        $sku = trim($pro['sku']);
        $product = Product::getBySku($pro['sku']);
        $mageId = trim($pro['product_id']);
        $name = trim($pro['name']);
        $short_description = trim($pro['short_description']);
        $description = trim($pro['description']);
        $weight = trim($pro['weight']);
        $statusId = trim($pro['status']);
        $price = trim($pro['price']);
        $specialPrice = trim($pro['special_price']);
        $specialPrice_From = trim($pro['special_from_date']) === '' ? trim($pro['special_from_date']) : null;
        $specialPrice_To = trim($pro['special_to_date']) === '' ? trim($pro['special_to_date']) : null;
        $supplierName = trim($pro['supplier']);
        $attributeSet = ProductAttributeSet::get(trim($pro['attributeSetId']));
        if (!$product instanceof Product) {
            $product = Product::create($sku, $name);
        }
        $asset = ($assetId = trim($product->getFullDescAssetId())) === '' || !($asset = Asset::getAsset($assetId)) instanceof Asset ? Asset::registerAsset('full_desc_' . $sku, $description, Asset::TYPE_PRODUCT_DEC) : $asset;
        $product->setName($name)->setMageId($mageId)->setAttributeSet($attributeSet)->setShortDescription($short_description)->setFullDescAssetId(trim($asset->getAssetId()))->setIsFromB2B(true)->setStatus(ProductStatus::get($statusId))->setSellOnWeb(true)->setManufacturer($clientScript->getManufacturerName(trim($pro['manufacturer'])))->save()->clearAllPrice()->addPrice(ProductPriceType::get(ProductPriceType::ID_RRP), $price)->addInfo(ProductInfoType::ID_WEIGHT, $weight);
        if ($specialPrice !== '') {
            $product->addPrice(ProductPriceType::get(ProductPriceType::ID_CASUAL_SPECIAL), $specialPrice, $specialPrice_From, $specialPrice_To);
        }
        if ($supplierName !== '') {
            $product->addSupplier(Supplier::create($supplierName, $supplierName, true));
        }
        if (isset($pro['categories']) && count($pro['categories']) > 0) {
            $product->clearAllCategory();
            foreach ($pro['categories'] as $cateMageId) {
                if (!($category = ProductCategory::getByMageId($cateMageId)) instanceof ProductCategory) {
                    continue;
                }
                $product->addCategory($category);
            }
        }
        if ($transStarted === false) {
            Dao::commitTransaction();
        }
        //TODO remove the file
        removeLineFromFile($fileName, $line);
        echo $product->getId() . " => done! \n";
    } catch (Exception $ex) {
        if ($transStarted === false) {
            Dao::rollbackTransaction();
        }
        throw $ex;
    }
}
 public function compose($view)
 {
     $productCategories = ProductCategory::live()->get();
     $items = array();
     foreach ($productCategories as $productCategory) {
         $items[$productCategory->getUrl()] = $productCategory->name;
     }
     $view->with('productCategories', $items);
 }
 public function getCategoryChildren()
 {
     $category = ProductCategory::get()->filter('ID', $this->CategoryID)->first();
     if ($category && $category->Children()->exists()) {
         return $category->Children();
     } else {
         return $category->Products();
     }
 }
 public function actionIndex()
 {
     $brand_id = isset($_GET['brand_id']) ? $_GET['brand_id'] : 0;
     $productCategoryOptions = ProductCategory::model()->byBrandOptions($brand_id);
     // 产品
     $criteria = new CDbCriteria();
     $criteria->compare('t.is_released', 1);
     $productarr = Product::model()->localized()->findAll($criteria);
     $brand = array();
     if ($brand_id != 0) {
         $criteria = new CDbCriteria();
         $criteria->compare('t.brand_id', $brand_id);
         $criteria->order = 'sort_order ASC';
         $brand = Brand::model()->localized()->find($criteria);
         $productCategoryOptions = ProductCategory::model()->byBrandOptions($brand_id);
         // 产品
         $criteria = new CDbCriteria();
         $criteria->compare('t.brand_id', $brand_id);
         $productarr = Product::model()->localized()->findAll($criteria);
     }
     $products = array();
     foreach ($productarr as $model) {
         $products[] = $model->attributes;
     }
     // 广告图
     $criteria = new CDbCriteria();
     $criteria->compare('t.banner_position_id', 1);
     $banner = Banner::model()->localized()->find($criteria);
     $brands = array();
     $criteria = new CDbCriteria();
     $criteria->select = 'brand_id,title';
     $criteria->compare('t.is_released', 1);
     $brandsarr = Brand::model()->localized()->findAll($criteria);
     foreach ($brandsarr as $model) {
         $brands[$model->brand_id] = $model->title;
     }
     $series = array();
     $criteria = new CDbCriteria();
     $criteria->select = 'series_id,title';
     $criteria->compare('t.is_released', 1);
     $seriesarr = ProductSeries::model()->localized()->findAll($criteria);
     foreach ($seriesarr as $model) {
         $series[$model->series_id] = $model->title;
     }
     $categorys = array();
     $criteria = new CDbCriteria();
     $criteria->select = 'category_id,name';
     $criteria->compare('t.is_released', 1);
     $categorysarr = ProductCategory::model()->localized()->findAll($criteria);
     foreach ($categorysarr as $model) {
         $categorys[$model->category_id] = $model->name;
     }
     $this->layout = 'main';
     $this->pageTitle = Yii::t('common', '产品中心') . SEPARATOR . Setting::getValueByCode('inside_title', true);
     $this->render('index', array('brand_id' => $brand_id, 'brand' => $brand, 'products' => $products, 'brands' => $brands, 'series' => $series, 'categorys' => $categorys, 'productCategoryOptions' => $productCategoryOptions, 'banner' => $banner));
 }
 /**
  * @return string
  */
 protected function renderControlEditable()
 {
     assert('$this->model instanceof Product || $this->model instanceof Product');
     $cClipWidget = new CClipWidget();
     $cClipWidget->beginClip("ModelElement");
     $cClipWidget->widget('application.core.widgets.MultiSelectAutoComplete', array('name' => $this->getNameForIdField(), 'id' => $this->getIdForIdField(), 'jsonEncodedIdsAndLabels' => CJSON::encode($this->getExistingProductCategoriesRelationsIdsAndLabels()), 'sourceUrl' => Yii::app()->createUrl('productTemplates/default/autoCompleteAllProductCategoriesForMultiSelectAutoComplete'), 'htmlOptions' => array('disabled' => $this->getDisabledValue()), 'hintText' => Zurmo::t('ProductsModule', 'Type a ' . ProductCategory::getModelLabelByTypeAndLanguage('SingularLowerCase'), LabelUtil::getTranslationParamsForAllModules())));
     $cClipWidget->endClip();
     $content = $cClipWidget->getController()->clips['ModelElement'];
     return $content;
 }
 public function getCategoryDetails($cat_id)
 {
     $category_details = array();
     $cat_details = ProductCategory::select('category_name', 'parent_category_id', 'id')->whereRaw('id = ?', array($cat_id))->first();
     if (count($cat_details) > 0) {
         $cat_details['full_parent_category_name'] = $this->getParentCategoryName($cat_details['id']);
         $category_details = $cat_details;
     }
     return $category_details;
 }
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'name';
     $types = ProductType::model()->findAll($criteria);
     $manufacturers = ProductManufacturer::model()->findAll($criteria);
     $categories = ProductCategory::model()->findAll($criteria);
     $data = array('types' => $types, 'manufacturers' => $manufacturers, 'categories' => $categories);
     $this->render('index', $data);
 }
 protected function renderContent()
 {
     $singularLabel = ProductCategory::getModelLabelByTypeAndLanguage('Singular');
     $pluralLabel = Zurmo::t('ProductTemplatesModule', 'Categories');
     $content = $this->renderViewToolBar(false);
     $content .= '<div>';
     $content .= $this->renderTreeMenu('productCategory', 'productCategories', $singularLabel);
     $content .= '</div>';
     return $content;
 }
Exemple #30
0
function search_products(ProductCategory $category, $page)
{
    $post_data = array();
    $post_data["ApiKey"] = API_KEY;
    $post_data["SearchRequest"] = array();
    $post_data["SearchRequest"]["Keyword"] = $category->get_name();
    $post_data["SearchRequest"]["Pagination"] = array();
    $post_data["SearchRequest"]["Pagination"]["ItemsPerPage"] = 10;
    $post_data["SearchRequest"]["Pagination"]["PageNumber"] = $page;
    $post_data["SearchRequest"]["Filters"] = array();
    $post_data["SearchRequest"]["Filters"]["Price"] = array();
    $post_data["SearchRequest"]["Filters"]["Price"]["Min"] = 0;
    $post_data["SearchRequest"]["Filters"]["Price"]["Max"] = 0;
    $post_data["SearchRequest"]["Filters"]["Navigation"] = "all";
    $post_data["SearchRequest"]["Filters"]["IncludeMarketPlace"] = false;
    $post_data["SearchRequest"]["Filters"]["Brands"] = array();
    $file = get_post_data(API_SEARCH, json_encode($post_data));
    return json_decode($file, true);
}