public function getAttributesForProduct(ProductModel $p, $limitCids = "") { $csv_cat = $p->getCategories(); $attrs = null; $attrsv = null; $attr_arr = array(); $prod_attrs = array(); if ($limitCids != "") { $csv_cat = $limitCids; } if ($csv_cat != "") { $attrs = $this->attrModel->fetchAttributes(array("cid" => "asc"), array("atr_categories" => trim($csv_cat, ","))); } if ($attrs != null) { foreach ($attrs as $k => $attr) { $csv_attrv = $attr->getId() . ","; $attr_arr[$attr->getId()]['name'] = $attr->getName(); $attr_arr[$attr->getId()]['value'] = ""; $attr_arr[$attr->getId()]['default_vals'] = json_decode($attr->getDefault_vals(), true); } $csv_attrv = trim($csv_attrv, ","); $attrsv = $this->attrValModel->fetchAttributesVal(array(), array("atrv_product" => $p->getProductId())); if ($attrsv != null) { foreach ($attrsv as $k => $attrv) { if (isset($attr_arr[$attrv->getAid()]['name'])) { $attr_arr[$attrv->getAid()]['value'] = $attrv->getApValue(); } } } return $attr_arr; } return null; }
public function addById($id, $data) { $pm = new ProductModel(); $pm->loadData($id); $arr = $pm->getProducts(); $product = $arr[0]; $product->setProperties($data); $this->addProduct($product); }
public function getVendorProductList() { $vendorId = isset($_REQUEST['vendorId']) ? (int) $_REQUEST['vendorId'] : null; $res = array(); if (!empty($vendorId)) { $model = new ProductModel(); $res = $model->getProductBasicinfoListByVendorId($vendorId); } echo json_encode($res); }
/** * Inserts product with given $id_article if $id_rubrique is ecatalogue rubrique */ function insert_product($id_article, $id_rubrique) { include_spip('classes/class.Ecatalogue'); include_spip('classes/class.ProductModel'); $catalogue = new Ecatalogue(); $product_mdl = new ProductModel(); if ($catalogue->IsEcatalogueRubrique($id_rubrique)) { $data['id_article'] = $id_article; $product_mdl->insert($data); } }
public function renderXml() { $this->template->items = dibi::query(' SELECT product.id_product AS id, product_lang.name, product_lang.description, product_lang.link_rewrite AS product_link, category_product.id_category AS id_category, category_lang.name AS category_name, category_lang.link_rewrite AS category_link FROM `product` LEFT JOIN product_lang USING (id_product) LEFT JOIN category_product USING (id_product) LEFT JOIN category_lang USING (id_category) WHERE product_lang.id_lang = 1 AND category_lang.id_lang = 1 GROUP BY (id_product)')->fetchAll(); $this->template->baseUri = 'http://www.matrace-rosty.sk'; $this->id_lang = 1; for ($i = 0; $i < count($this->template->items); $i++) { $productWithLowestPrice = dibi::query('SELECT * FROM product_param WHERE id_product = %i', $this->template->items[$i]['id'], ' ORDER BY price LIMIT 0,1')->fetch(); $this->template->items[$i]['url'] = $this->getPresenter()->link('Eshop:current', array('categories' => $this->template->items[$i]['category_link'], 'url_identifier' => NStrings::webalize($this->template->items[$i]['product_link']))); $this->template->items[$i]['image'] = ProductModel::getImage($this->template->items[$i]['id']); $this->template->items[$i]['price_vat'] = round($productWithLowestPrice['price'], 2); $this->template->items[$i]['price'] = round($this->template->items[$i]['price_vat'] / 1.2, 2); $this->template->items[$i]['vat'] = '0.20'; $this->template->items[$i]['size'] = $productWithLowestPrice['size']; $this->template->items[$i]['material'] = $productWithLowestPrice['material']; } }
public function IndexAction() { Site::$keywords = $this->company->tags; Site::$title = $this->company->name . ' на PromSpace'; $group_tags_array = GroupModel::GetList(); $region_tags_array = RegionModel::GetList(); $region_tags_array[0] = 'Вся Россия'; $group_tags_array[0] = 'Не определено'; $products = ProductModel::GetAll()->where('company_id = ?', [0 => $this->company->id]); $contacts = array(); if (!User::isLogged()) { if ($this->company->open == 2) { $contacts = ContactsModel::GetAll()->where('company_id = ?', [0 => $this->company->id]); } $this->render('nologged', ['company' => $this->company, 'group_tags' => $group_tags_array, 'region_tags' => $region_tags_array, 'contacts' => $contacts, 'products' => $products, 'simmilar' => $this->GetSimmilar()]); } elseif ($this->company->id == User::company() or User::admin()) { if ($this->company->logo == '') { Site::Message('Мы рекомендуем Вам установить логтип для профиля, это сделает его более привлекательным для клиентов'); } $contacts = ContactsModel::GetAll()->where('company_id = ?', [0 => $this->company->id]); $this->render('edit', ['company' => $this->company, 'group_tags' => $group_tags_array, 'region_tags' => $region_tags_array, 'contacts' => $contacts, 'products' => $products, 'simmilar' => $this->GetSimmilar()]); } else { if ($this->company->open == 0 and FavoriteModel::i_friend($this->company->id) or $this->company->open > 0) { $contacts = ContactsModel::GetAll()->where('company_id = ?', [0 => $this->company->id]); } $this->render('index', ['company' => $this->company, 'group_tags' => $group_tags_array, 'region_tags' => $region_tags_array, 'favorite' => FavoriteModel::my_friend($this->company->id) ? 'favorite.png' : 'star.png', 'contacts' => $contacts, 'products' => $products, 'simmilar' => $this->GetSimmilar()]); } }
public function saveProducts() { $products = $_SESSION['products']; ProductModel::saveData($products, "products"); unset($_SESSION['products']); $this->renderView("/processFile/configFiles"); }
public function renderDefault() { //uvod $home = dibi::fetch("SELECT * FROM [menu_item] WHERE home = 1 AND lang = %s", $this->lang); if (!$home) { $home = dibi::fetch("SELECT * FROM [menu_item] WHERE lang = %s", $this->lang, "ORDER BY sequence LIMIT 1"); } $this->template->id_menu_item = $home['id_menu_item']; /* * META INFO */ $this['header']->addTitle($home['meta_title']); $this['header']->setDescription($home['meta_description']); $node = $this->getService('Node'); $query = $node->getAll($this->template->id_menu_item); $this->template->node_list = $query->fetchAll(); //produkty na uvode $list = dibi::select('id_product')->from('product')->where('home = 1'); $count_list = clone $list; $count = $count_list->removeClause('select')->select('COUNT(id_product)')->fetchSingle(); $vp = new VisualPaginator($this, 'paginator'); $paginator = $vp->getPaginator(); $paginator->itemsPerPage = 12; $paginator->itemCount = (int) $count; $this->template->products = $list->limit($paginator->offset . ',' . $paginator->itemsPerPage)->fetchAll(); $this->template->paginator = $paginator; foreach ($this->template->products as $k => $p) { $this->template->products[$k] = ProductModel::getProductWithParams($p['id_product'], $this->id_lang, $this->user); } /* widget */ $this['productNewsSaleAvaiableTable']->setIdLang($this->id_lang); $this['productNewsSaleAvaiableTable']->setUser($this->user); }
public function renderDefault($id, $id_category) { if (!$id) { throw new NBadRequestException('Product neexistuje'); } $this->template->id_category = $id_category; $this->template->category_parents = CategoryModel::getParents($this->template->id_category, $this->id_lang); $this->template->product = ProductModel::getProductWithParams($id, $this->id_lang, $this->user); $this['productNewsSaleAvaiableTable']->setIdProduct($id); $this['productNewsSaleAvaiableTable']->setIdCategory($id_category); $this['productNewsSaleAvaiableTable']->setIdLang($this->id_lang); $this['productNewsSaleAvaiableTable']->setUser($this->user); /* * META INFO */ if ($this->template->product) { if ($this->template->product['meta_title'] == '') { $this['header']->addTitle($this->template->product['name']); } else { $this['header']->addTitle($this->template->product['meta_title']); } if ($this->template->product['meta_description'] == '') { $this['header']->setDescription($this->template->product['name']); } else { $this['header']->setDescription($this->template->product['meta_description']); } $this['header']->addKeywords($this->template->product['meta_keywords']); } $this['header']['js']->addFile('jquery/bubblepopup/jquery.bubblepopup.v2.3.1.min.js'); $this['header']['css']->addFile('../jscripts/jquery/bubblepopup/jquery.bubblepopup.v2.3.1.css'); }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->products = ''; $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; $this->Template->relateds_headline = $GLOBALS['TL_LANG']['MSC']['relateds_headline']; $objProduct = \ProductModel::findPublishedByParentAndIdOrAlias(\Input::get('items'), $this->catalogs); if (null === $objProduct) { /** @var \PageError404 $objHandler */ $objHandler = new $GLOBALS['TL_PTY']['error_404'](); $objHandler->generate($objPage->id); } // Overwrite the page title if ($objProduct->title != '') { $objPage->pageTitle = strip_tags(strip_insert_tags($objProduct->title)); } // Overwrite the page description if ($objProduct->description != '') { $objPage->description = $this->prepareMetaDescription($objProduct->description); } $arrProduct = $this->parseProduct($objProduct); $this->Template->product = $arrProduct; $objProduct->related = deserialize($objProduct->related); if (!empty($objProduct->related)) { $objProducts = \ProductModel::findPublishedByIds($objProduct->related); $this->Template->relateds = $this->parseRelateds($objProducts); } }
function renderXml_old() { //$this->id_lang $this->template->items = dibi::query(' SELECT product.id_product AS id, product_lang.name, product_lang.meta_description, product_lang.link_rewrite AS product_link, category_product.id_category AS id_category, category_lang.name AS category_name, category_lang.link_rewrite AS category_link FROM `product` LEFT JOIN product_lang USING (id_product) LEFT JOIN category_product USING (id_product) LEFT JOIN category_lang USING (id_category) WHERE product_lang.id_lang = 1 AND category_lang.id_lang = 1 GROUP BY (id_product)')->fetchAll(); $this->template->baseUri = 'http://' . $_SERVER['HTTP_HOST']; $this->id_lang = 1; for ($i = 0; $i < count($this->template->items); $i++) { $this->template->items[$i]['url'] = $this->link(':Front:Product:default', array('id' => $this->template->items[$i]['id'], 'id_category' => $this->template->items[$i]['id_category'])); $this->template->items[$i]['image'] = ProductModel::getImage($this->template->items[$i]['id']); $this->template->items[$i]['price_vat'] = round($productWithLowestPrice['price'], 2); $this->template->items[$i]['price'] = round($this->template->items[$i]['price_vat'] / 1.2, 2); $this->template->items[$i]['vat'] = '0.20'; $this->template->items[$i]['size'] = $productWithLowestPrice['size']; $this->template->items[$i]['material'] = $productWithLowestPrice['material']; } dde($this->template->items); }
function beforeRender() { parent::beforeRender(); $this->template->id_category = $this->id; $this->template->category_parents = CategoryModel::getParents($this->template->id_category, $this->id_lang); //ak je iba jeden parent zobraz kategorie, inak zobraz produkty if (count($this->template->category_parents) == 1) { $id_parent = current($this->template->category_parents); $category_list = CategoryModel::getFluent('id_category')->where('id_parent = %i', $id_parent)->fetchAll(); $this->template->categories = array(); foreach ($category_list as $l) { $_tmp = CategoryModel::get($l->id_category, $this->id_lang); $_tmp['product_count'] = dibi::fetchSingle("SELECT COUNT(id_product) FROM [product] JOIN [category_product] USING(id_product) WHERE id_category = %i", $l->id_category); $this->template->categories[] = $_tmp; } $this->template->product_count = dibi::fetchSingle("SELECT COUNT(id_product) FROM [product] JOIN [category_product] USING(id_product) WHERE id_category = %i", $this->id); } else { $list = dibi::select('id_product')->from('product')->join('category_product')->using('(id_product)')->join('product_param')->using('(id_product)')->where('id_category = ', $this->id, 'AND product.active = 1'); /* * Filter */ $orderSession = $this['quickFilter']->getSession(); // dde($orderSession['order']); // $orderSession['order'] = 'price'; if ($orderSession['order']) { $list->orderBy($orderSession['order']); } else { $order_array = $this['quickFilter']->getOrderFilterArray(); $list->orderBy(key($order_array)); } $list->groupBy('id_product'); // dump($order); // print_r($list); $count_list = clone $list; // $count = $count_list->removeClause('select')->select('COUNT(id_product)')->fetchSingle(); $count = count($count_list); $vp = new VisualPaginator($this, 'paginator'); $paginator = $vp->getPaginator(); $numOnPageSession = $this['quickFilter']->getSession(); if ($numOnPageSession['num']) { $paginator->itemsPerPage = $numOnPageSession['num']; } else { $num_on_page_array = $this['quickFilter']->getNumOnPageFilterArray(); $paginator->itemsPerPage = key($num_on_page_array); } $paginator->itemCount = (int) $count; $this->template->product_count = $count; $this->template->products = $list->limit($paginator->offset . ',' . $paginator->itemsPerPage)->fetchAll(); //dump($this->template->products); $this->template->paginator = $paginator; foreach ($this->template->products as $k => $p) { $this->template->products[$k] = ProductModel::getProductWithParams($p['id_product'], $this->id_lang, $this->user); } // }; } // print_r($this->template->products);exit; }
function handleAdd($id_product_param, $count) { $product = ProductModel::getProductIdentifyByParam($id_product_param, $this->getPresenter()->id_lang, $this->getPresenter()->user); $item = new \ShoppingCart\Item(); $item = $this->repository->mapper->load($product); //$this->repository->deleteAll(); $this->repository->add($item, $count); $this->invalidateControl('defaultcart'); }
/** * Add product items to the indexer * @param array * @param integer * @param boolean * @return array */ public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false) { $arrRoot = array(); if ($intRoot > 0) { $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page'); } $time = time(); $arrProcessed = array(); // Get all catalog categories $objCatalog = \ProductCatalogModel::findByProtected(''); // Walk through each archive if ($objCatalog !== null) { while ($objCatalog->next()) { // Skip catalog categories without target page if (!$objCatalog->jumpTo) { continue; } // Skip catalog categories outside the root nodes if (!empty($arrRoot) && !in_array($objCatalog->jumpTo, $arrRoot)) { continue; } // Get the URL of the jumpTo page if (!isset($arrProcessed[$objCatalog->jumpTo])) { $objParent = \PageModel::findWithDetails($objCatalog->jumpTo); // The target page does not exist if ($objParent === null) { continue; } // The target page has not been published (see #5520) if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop < $time) { continue; } // The target page is exempt from the sitemap (see #6418) if ($blnIsSitemap && $objParent->sitemap == 'map_never') { continue; } // Set the domain (see #6421) $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/'; // Generate the URL $arrProcessed[$objCatalog->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language); } $strUrl = $arrProcessed[$objCatalog->jumpTo]; // Get the items $objProduct = \ProductModel::findPublishedByPid($objCatalog->id); if ($objProduct !== null) { while ($objProduct->next()) { $objElement = \ContentModel::findPublishedByPidAndTable($objProduct->id, 'tl_product'); if ($objElement !== null) { $arrPages[] = $this->getLink($objProduct, $strUrl); } } } } } return $arrPages; }
static function getProducts($limit, $offset, $filters = null) { // TODO implement filterings $productObjects = ProductModel::all(array('limit' => $limit, 'offset' => $offset)); $products = array(); foreach ($productObjects as $p) { $products[] = Activerecord::returnArrayWithLang($p); } return $products; }
function act_getNewGoodsList($select, $where) { $list = ProductModel::getNewGoodsList($select, $where); if ($list) { return $list; } else { self::$errCode = ProductModel::$errCode; self::$errMsg = OrderTestModel::$errMsg; return false; } }
function actionDefault($q = NULL, $sale = 0, $news = 0, $top = 0) { $this->q = str_replace('%', '', $q); $this->sale = $sale; $this->news = $news; $this->top = $top; $this->template->showForm = true; $list = self::getQuery(); if ($this->sale == 1) { $list->where('product.sale = 1'); $this->template->name = 'Akciový tovar'; $this->template->showForm = false; } if ($this->news == 1) { $list->where('product.news = 1'); $this->template->name = 'Novinky'; $this->template->showForm = false; } if ($this->top == 1) { $list->where('product.our_tip = 1'); $this->template->name = 'TOP Produkty'; $this->template->showForm = false; } if ($this->q != '') { $list->where(' ( product_lang.name LIKE %s', '%' . $this->q . '%', ' OR product_lang.description LIKE %s', '%' . $this->q . '%', ' OR product_param.code LIKE %s', $this->q, ' ) '); $this->template->name = 'Vyhľadávanie slova: ' . $this->q; } $list->groupBy('id_product'); /* * breadcrumb */ if (!isset($this->template->name)) { $this->template->name = 'Vyhľadávanie'; } $this->template->breadcrumb = array(); $this->template->breadcrumb[] = array('link' => $this->link('this'), 'name' => $this->template->name); // $count_list = clone $list; $count = $this->template->count = count($list); $vp = new VisualPaginator($this, 'paginator'); $paginator = $vp->getPaginator(); $paginator->itemsPerPage = 70; $paginator->itemCount = (int) $count; $this->template->products = $list->limit($paginator->offset . ',' . $paginator->itemsPerPage)->fetchAll(); $this->template->paginator = $paginator; foreach ($this->template->products as $k => $p) { $this->template->products[$k] = ProductModel::getProductWithParams($p['id_product'], $this->id_lang, $this->user); } }
function getProducts($params) { // check params if (!is_object($params)) { JsonRpc::setInvalidParamsError($this); return null; } // expected params are offset/count/filters(object)/order_by/order_dir. // for now the filters will include category/search_term/price_lower/price_higher/code/sale(y/n)/in_stock return ProductModel::getProducts($params->limit, $params->offset, $params->filters); }
protected function crawl() { $products = ProductModel::findAll(); foreach ($products as $product) { sleep(0.2); $html = $this->requestProductPage($product->url); if ($html) { $this->parseProduct($html, $product); } } }
public function item() { // we want to display published nodes only if (!(UserModel::getLoggedIn() && UserModel::getLoggedIn()->isAdmin())) { Ajde::app()->getRequest()->set('filterPublished', true); } // get the current slug $slug = $this->getSlug(); /* @var $product ProductModel */ $product = new ProductModel(); $product->loadBySlug($slug); $this->product = $product; if ($product->getPublished() === false) { Ajde_Dump::warn('Previewing unpublished product'); } // check if we have a hit if (!$product->hasLoaded()) { Ajde::app()->getResponse()->redirectNotFound(); } Ajde_Event::trigger($this, 'onAfterProductLoaded', [$product]); // update cache Ajde_Cache::getInstance()->updateHash($product->hash()); Ajde_Cache::getInstance()->addLastModified(strtotime($product->updated)); // set title if (!Ajde::app()->getDocument()->hasNotEmpty('title')) { Ajde::app()->getDocument()->setTitle($product->getTitle()); } // set summary if ($product->content) { Ajde::app()->getDocument()->setDescription(Ajde_Component_String::trim(strip_tags($product->content), '100')); } // set author $product->loadParent('user'); /** @var UserModel $owner */ $owner = $product->getUser(); Ajde::app()->getDocument()->setAuthor($owner->getFullname()); // featured image if ($image = $product->featuredImage()) { Ajde::app()->getDocument()->setFeaturedImage($image); } // pass node to view $this->setAction('item'); $this->getView()->assign('product', $product); // render the template return $this->render(); }
public function getPageContent() { $model = new ProductModel(); $model->loadData(intval($_GET["id"])); $products = $model->getProducts(); if (count($products) !== 1) { return ""; } $id = $products[0]->getId(); $price = $products[0]->getPrice(); $template = $this->getTemplateEngine()->readTemplate($this->getTemplate()); $template = $this->getTemplateEngine()->replaceTag("name-de", $this->getValue($id, "name", "de"), $template); $template = $this->getTemplateEngine()->replaceTag("name-en", $this->getValue($id, "name", "en"), $template); $template = $this->getTemplateEngine()->replaceTag("name-fr", $this->getValue($id, "name", "fr"), $template); $template = $this->getTemplateEngine()->replaceTag("description-de", $this->getValue($id, "description", "de"), $template); $template = $this->getTemplateEngine()->replaceTag("description-en", $this->getValue($id, "description", "en"), $template); $template = $this->getTemplateEngine()->replaceTag("description-fr", $this->getValue($id, "description", "fr"), $template); $template = $this->getTemplateEngine()->replaceTag("price", $price, $template); $template = $this->getTemplateEngine()->replaceTag("id", $id, $template); return $template; }
/** * 默认动作 * Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参 * 对于如下的例子, 当访问http://yourhost/y/index/index/index/name/yantze 的时候, 你就会发现不同 */ public function indexAction() { $site = new OptionModel(); $product = new ProductModel(); $page = $this->getRequest()->getQuery("page"); $size = $this->getRequest()->getQuery("size"); if (!($page && $size)) { $page = 1; $size = 12; } $itemlist = $product->selectPage($page, $size); $maxNum = $product->selectAll_num(); $siteInfo = $site->selectAll(); $this->getView()->assign("name", $siteInfo[0]['value']); $this->getView()->assign("desc", $siteInfo[1]['value']); $this->getView()->assign("items", $itemlist); $this->getView()->assign("maxNum", intval($maxNum)); $this->getView()->assign("curPage", intval($page)); $this->getView()->assign("curSize", intval($size)); return true; }
public function getPageContent() { $model = new ProductModel(); $model->loadData(null); $products = $model->getProducts(); if (count($products) === 0) { return "dafuq"; } $template = $this->getTemplateEngine()->readTemplate($this->getTemplate()); $rows = ""; foreach ($products as $product) { $path = "images/products/" . $product->getClassification() . "/" . $product->getType() . "/" . $product->getImgname(); $row = $this->getTemplateEngine()->readTemplate(Template::ADMIN_DELETE_ROW); $row = $this->getTemplateEngine()->replaceTag("id", $product->getId(), $row); $row = $this->getTemplateEngine()->replaceTag("imgpath", $path, $row); $row = $this->getTemplateEngine()->replaceTag("name", $product->getName(), $row); $rows .= $row; } $template = $this->getTemplateEngine()->replaceTag("rows", $rows, $template); return $template; }
static function insertNew() { $id_vat = NEnvironment::getService('Vat')->getDefault(); $id_product_template_group = NEnvironment::getService('ProductTemplateGroupModel')->getIdDefaultTemplate(); $id_product = self::add(array('active' => 0, 'adddate' => new DibiDateTime(), 'added' => 0, 'id_vat' => $id_vat, 'id_product_template_group' => $id_product_template_group)); $langs = Setting::getLangs(); foreach ($langs as $l) { $lang_val = array('id_product' => $id_product, 'id_lang' => $l['id_lang']); ProductModel::addProductLang($lang_val); } return $id_product; }
function formulaires_ecatalogue_product_equipment_traiter_dist($id_article) { $result = array(); $result_flag = true; $mdl = new ProductModel(); $data = array(); if ($id_article_add = _request('id_article_add')) { $data['id_equipment'] = _request('id_equipment'); $result_flag = $mdl->update_by_id($id_article_add, $data, true); } if ($id_article_delete = _request('id_article_delete')) { $data['id_equipment'] = $mdl->GetMaxIdEquipment() + 1; $result_flag = $mdl->update_by_id($id_article_delete, $data, true); } if ($result_flag) { $result['message_ok'] = _T('ecatalogue:form_saved'); } else { $result['message_erreur'] = _T('ecatalogue:form_error'); } set_request('id_article_add'); set_request('id_article_delete'); return $result; }
function renderDefault($query) { $this->template->query = $query; if ($query != '') { $vp = new VisualPaginator($this, 'vp'); try { $datasource = ProductModel::searching($this->id_lang, $query); $paginator = $vp->getPaginator(); $paginator->itemsPerPage = 2; $paginator->itemCount = $itemsCount = count($datasource); if ($itemsCount == 0) { throw new ProductException(_('Hľadaný výraz sa nenašiel.')); } $this->template->searchingItems = $datasource->applyLimit($paginator->itemsPerPage, $paginator->offset)->fetchAll(); //zisti pre kazdy clanok url_identifier foreach ($this->template->searchingItems as $k => $i) { $this->template->searchingItems[$k]['url'] = $this->getPresenter()->link('Eshop:current', array('categories' => $i['category_link_rewrite'], 'url_identifier' => $i['link_rewrite'])); $image = FilesNode::getOneFirstFile('product', $i['id_product']); if ($image) { $image['thumbs'] = Files::gURL($image['src'], $image['ext'], 100, 70, 5); $this->template->searchingItems[$k]['image'] = $image; } } } catch (ProductException $e) { $this->flashMessage($e->getMessage()); } } else { $this->redirect('Homepage'); } // // try{ // // $this->template->searching_list = ProductModel::searching($this->lang, $query)->fetchAll(); // if(empty($this->template->searching_list)){ // $this->flashMessage('Hľadaný výraz sa nenašiel.'); // } // foreach($this->template->searching_list as $k=>$l){ // // $this->template->searching_list[$k]['url'] = $this->link('List:current', // array('categories'=> MenuModel::getUrl($l['id_menu_item']) , // 'url_identifier'=>$l['url_identifier']) ); // // } // // }catch(ProductException $e){ // $this->flashMessage($e->getMessage()); // } // }
protected function parseProductsList($html, $category) { $parser = new NewhtfProductsListParser($html); foreach ($parser->products_list as $data) { $entity = ProductModel::findOneByUrl($data['url']); if (!$entity) { $entity = new Product(); } $data['category_id'] = $category->id; $entity->fromArray($data); $entity->save(); $this->sendBuffered('product: ' . $entity->url); } //$category->processed = 1; //$category->save(); }
public function actionSearch() { $keyword = Yii::app()->request->getParam('q'); if ($keyword == '') { $this->redirect(Yii::app()->homeUrl); } $keyword = Common::RemoveXSS($keyword); $order = Yii::app()->request->getParam('order', 1); $channel = strtolower(Yii::app()->request->getParam('channel', 'web')); $pagesize = 12; $count = ProductModel::model()->countsearchProduct($channel, $keyword); $page = new CPagination($count); $page->pageSize = $pagesize; $product_web = ProductModel::model()->searchProduct($channel, $keyword, $order, $page->getLimit(), $page->getOffset()); $this->render('search', compact('product_web', 'page', 'keyword', 'order', 'channel', 'count')); }
public function detectShopSlug(Ajde_Core_Route $route) { $slug = $route->getRoute(); $slug = trim($slug, '/'); $lastSlash = strrpos($slug, '/'); if ($lastSlash !== false) { $lastSlugPart = substr($slug, $lastSlash + 1); $product = ProductModel::fromSlug($lastSlugPart); if ($product) { $route->setRoute($slug); $routes = config('routes.list'); array_unshift($routes, ['%^(shop)/(' . preg_quote($lastSlugPart) . ')$%' => ['module', 'slug']]); Config::set('routes.list', $routes); } } }
public function DeleteAction() { $id = intval(Request::GetPart(3)); $product = ProductModel::GetObj()->where('id = ? AND company_id = ?', [0 => $id, 1 => $this->company->id]); if ($product->id > 0) { ProductModel::delete()->id($product->id); } if ($product->pic != '') { if (file_exists(ROOT . '/web/files/' . $product->pic)) { unlink(ROOT . '/web/files/' . $product->pic); } if (file_exists(ROOT . '/web/files/s_' . $product->pic)) { unlink(ROOT . '/web/files/s_' . $product->pic); } } Site::Message('Продукт успешно удалён'); $this->route('profile'); }