Inheritance: extends MX_Controller
 function update(Manufacturer $man)
 {
     $query = "UPDATE `manufacturer` SET `idmanufacturer`='" . $man->getIdmanufacturer() . "',`manufacturer_name`='" . $man->getManufacturerName() . "',`address_number`='" . $man->getAddressNumber() . "',`address_street`='" . $man->getAddressStreet() . "',`address_city`='" . $man->getAddressCity() . "',`address_country`='" . $man->getAddressCountry() . "',`contact_number`='" . $man->getContactNumber() . "' WHERE `idmanufacturer`='" . $man->getIdmanufacturer() . "'";
     $this->con->openConnection();
     $this->con->executeRawQuery($query);
     $this->con->closeConnection();
 }
Example #2
0
 public function getTemplateVarSitemap()
 {
     $pages = [];
     $catalog_mode = Configuration::isCatalogMode();
     $cms = CMSCategory::getRecurseCategory($this->context->language->id, 1, 1, 1);
     foreach ($cms['cms'] as $p) {
         $pages[] = ['id' => 'cms-page-' . $p['id_cms'], 'label' => $p['meta_title'], 'url' => $this->context->link->getCMSLink(new CMS($p['id_cms']))];
     }
     $pages[] = ['id' => 'stores-page', 'label' => $this->trans('Our stores', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('stores')];
     $pages[] = ['id' => 'contact-page', 'label' => $this->trans('Contact us', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('contact')];
     $pages[] = ['id' => 'sitemap-page', 'label' => $this->trans('Sitemap', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('sitemap')];
     $pages[] = ['id' => 'login-page', 'label' => $this->trans('Log in', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('authentication')];
     $pages[] = ['id' => 'register-page', 'label' => $this->trans('Create new account', array(), 'Shop.Theme'), 'url' => $this->context->link->getPageLink('authentication')];
     $catalog = ['new-product' => ['id' => 'new-product-page', 'label' => $this->trans('New products', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('new-products')]];
     if ($catalog_mode && Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
         $catalog['best-sales'] = ['id' => 'best-sales-page', 'label' => $this->trans('Best sellers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('best-sales')];
         $catalog['prices-drop'] = ['id' => 'prices-drop-page', 'label' => $this->trans('Price drop', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('prices-drop')];
     }
     if (Configuration::get('PS_DISPLAY_SUPPLIERS')) {
         $manufacturers = Manufacturer::getLiteManufacturersList($this->context->language->id, 'sitemap');
         $catalog['manufacturer'] = ['id' => 'manufacturer-page', 'label' => $this->trans('Manufacturers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('manufacturer'), 'children' => $manufacturers];
         $suppliers = Supplier::getLiteSuppliersList($this->context->language->id, 'sitemap');
         $catalog['supplier'] = ['id' => 'supplier-page', 'label' => $this->trans('Suppliers', array(), 'Shop.Theme.Catalog'), 'url' => $this->context->link->getPageLink('supplier'), 'children' => $suppliers];
     }
     $categories = Category::getRootCategory()->recurseLiteCategTree(0, 0, null, null, 'sitemap');
     $catalog['category'] = ['id' => 'category-page', 'label' => $this->trans('Categories', array(), 'Shop.Theme.Catalog'), 'url' => '#', 'children' => $categories['children']];
     $sitemap = [['id' => 'page-page', 'label' => $this->trans('Pages', array(), 'Shop.Theme'), 'url' => '#', 'children' => $pages], ['id' => 'catalog-page', 'label' => $this->trans('Catalog', array(), 'Shop.Theme'), 'url' => '#', 'children' => $catalog]];
     return $sitemap;
 }
 public function hookProductFooter($params)
 {
     $id_product = (int) $params['product']->id;
     $product = $params['product'];
     if (isset($params['product']->id_manufacturer) && $params['product']->id_manufacturer) {
         $cache_id = 'productsmanufacturer|' . $id_product . '|' . (int) $params['product']->id_manufacturer;
         if (!$this->isCached('productsmanufacturer.tpl', $this->getCacheId($cache_id))) {
             // Get infos
             $manufacturer_products = Manufacturer::getProducts($params['product']->id_manufacturer, $this->context->language->id, 1, Configuration::get('pmslid_limit'));
             /* 100 products max. */
             // Remove current product from the list
             if (is_array($manufacturer_products) && count($manufacturer_products)) {
                 foreach ($manufacturer_products as $key => $manufacturer_product) {
                     if ($manufacturer_product['id_product'] == $id_product) {
                         unset($manufacturer_products[$key]);
                         break;
                     }
                 }
                 $taxes = Product::getTaxCalculationMethod();
                 if (!Configuration::get('pmslid_DISPLAY_PRICE')) {
                     foreach ($manufacturer_products as $key => $manufacturer_product) {
                         if ($manufacturer_product['id_product'] != $id_product) {
                             $manufacturer_products[$key]['show_price'] = 0;
                         }
                     }
                 }
             }
             // Display tpl
             $this->smarty->assign(array('manufacturer_products' => $manufacturer_products, 'ProdDisplayPrice' => Configuration::get('pmslid_DISPLAY_PRICE')));
         }
         return $this->display(__FILE__, 'productsmanufacturer.tpl', $this->getCacheId($cache_id));
     }
 }
 public function run()
 {
     $inn = false;
     $cat = Category::model()->with('categoryDescriptions')->find('categoryDescriptions.link=:link', array(':link' => $this->current));
     if (!empty($cat)) {
         $catName = $cat->getName();
         $categories = $cat->categories;
         if (empty($categories)) {
             $categories = array($cat);
             $inn = true;
         }
         //echo print_r($categories);
     } else {
         $catName = 'All';
         $categories = Category::model()->findAll();
     }
     $products = array();
     $nbrands = $brands = array();
     foreach ($categories as $category) {
         $products = array_merge($products, $category->products);
     }
     foreach ($products as $product) {
         $nbrands[] = $product->manufacturer_id;
     }
     $nbrands = array_unique($nbrands, SORT_NUMERIC);
     foreach ($nbrands as $nbrand) {
         $manu = Manufacturer::model()->findByPk($nbrand);
         if (!empty($manu)) {
             $brands[$nbrand] = $manu->name;
         }
     }
     //$brands = asort($brands);
     $this->render('category_navigation', array('inn' => $inn, 'cat' => $cat, 'name' => $catName, 'categories' => $categories, 'products' => $products, 'brands' => $brands, 'current' => $this->current));
 }
 public function hookLeftColumn($params)
 {
     if (!$this->isCached('blockmanufacturer.tpl', $this->getCacheId())) {
         $this->smarty->assign(array('manufacturers' => Manufacturer::getManufacturers(), 'text_list' => Configuration::get('MANUFACTURER_DISPLAY_TEXT'), 'text_list_nb' => Configuration::get('MANUFACTURER_DISPLAY_TEXT_NB'), 'form_list' => Configuration::get('MANUFACTURER_DISPLAY_FORM'), 'display_link_manufacturer' => Configuration::get('PS_DISPLAY_SUPPLIERS')));
     }
     return $this->display(__FILE__, 'blockmanufacturer.tpl', $this->getCacheId());
 }
 /**
  * Display the specified dashboard.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $products = Product::all();
     $records = Record::all();
     $manufacturers = Manufacturer::all();
     return View::make('Dashboard.index', compact('records', 'products', 'manufacturers'));
 }
 public function renderForm()
 {
     if (!$this->object->id) {
         $this->object->price = -1;
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Catalog price rules'), 'icon' => 'icon-dollar'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop'), 'name' => 'shop_id', 'options' => array('query' => Shop::getShops(), 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->l('Currency'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Group'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('From quantity'), 'name' => 'from_quantity', 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.)'), 'name' => 'price', 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Leave base price'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'datetime', 'label' => $this->l('From'), 'name' => 'from'), array('type' => 'datetime', 'label' => $this->l('To'), 'name' => 'to'), array('type' => 'select', 'label' => $this->l('Reduction type'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Reduction with or without taxes'), 'name' => 'reduction_tax', 'align' => 'center', 'options' => array('query' => array(array('lab' => $this->l('Tax included'), 'val' => 1), array('lab' => $this->l('Tax excluded'), 'val' => 0)), 'id' => 'val', 'name' => 'lab')), array('type' => 'text', 'label' => $this->l('Reduction'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save')));
     if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
         $price = number_format($value, 6);
     } else {
         $price = '';
     }
     $this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 6), 'leave_bprice_on' => $price ? 0 : 1);
     $attribute_groups = array();
     $attributes = Attribute::getAttributes((int) $this->context->language->id);
     foreach ($attributes as $attribute) {
         if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
             $attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
         }
         $attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
     }
     $features = Feature::getFeatures((int) $this->context->language->id);
     foreach ($features as &$feature) {
         $feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
     }
     $this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
     return parent::renderForm();
 }
Example #8
0
 public function testEavQueue()
 {
     // set up Manufacturer records
     $field = EavField::getNewInstance('Manufacturer', EavField::DATATYPE_TEXT, EavField::TYPE_TEXT_SIMPLE);
     $field->save();
     $data = array('first', 'second', 'third');
     foreach ($data as $value) {
         $manufacturer = Manufacturer::getNewInstance($value);
         $manufacturer->getSpecification()->setAttributeValueByLang($field, 'en', $value . ' test');
         $manufacturer->save();
     }
     ActiveRecordModel::clearPool();
     // fetch them from database
     $manufacturers = ActiveRecordModel::getRecordSetArray('Manufacturer', new ARSelectFilter());
     foreach ($manufacturers as &$entry) {
         ActiveRecordModel::addToEavQueue('Manufacturer', $entry);
     }
     // duplicate
     $manufacturers = array_merge($manufacturers, $manufacturers);
     // load EAV data
     ActiveRecordModel::loadEav();
     foreach ($manufacturers as $man) {
         $this->assertEqual($man['name'] . ' test', $man['attributes'][$field->getID()]['value_en']);
     }
 }
Example #9
0
 /**
  * (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;
 }
 function hookHome($params)
 {
     global $smarty, $cookie;
     $manufacturer = Manufacturer::getManufacturers(false, $cookie->id_lang, true);
     $smarty->assign(array('manufacturer' => $manufacturer));
     return $this->display(__FILE__, 'tdmanufacturerblock.tpl');
 }
 public function loadModel($id)
 {
     $model = Manufacturer::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function actionAutocomplete($query)
 {
     $json = array();
     $manufacturers = Manufacturer::model()->findAll("name LIKE '%{$query}%' ");
     foreach ($manufacturers as $manufacturer) {
         $json[] = array('id' => $manufacturer->manufacturer_id, 'value' => $manufacturer->name);
     }
     echo CJSON::encode($json);
 }
 /**
  * Method postProcess() : add or update manufacturer object
  *
  * @module now_seo_links
  * @return object Manufacturer
  *
  * @see AdminManufacturersControllerCore::postProcess()
  */
 public function postProcess()
 {
     $aShops = array_keys(Tools::getValue('checkBoxShopAsso_manufacturer', array()));
     // Check if name already exist
     if (Manufacturer::nameIsAlreadyUsed(Tools::getValue('id_manufacturer'), Tools::getValue('name'), $aShops)) {
         $this->errors[] = Tools::displayError('Ce nom de marque existe déjà et ne peut être utilisé une nouvelle fois.');
     }
     return parent::postProcess();
 }
Example #14
0
 /**
  * Create a link to a product
  *
  * @param mixed $product Product object (can be an ID product, but deprecated)
  * @param string $alias
  * @param string $category
  * @param string $ean13
  * @param int $id_lang
  * @param int $id_shop (since 1.5.0) ID shop need to be used when we generate a product link for a product in a cart
  * @param int $ipa ID product attribute
  * @return string
  */
 public function getProductLink($product, $alias = null, $category = null, $ean13 = null, $id_lang = null, $id_shop = null, $ipa = 0, $force_routes = false, $relative_protocol = false, $add_anchor = false)
 {
     $dispatcher = Dispatcher::getInstance();
     if (!$id_lang) {
         $id_lang = Context::getContext()->language->id;
     }
     $url = $this->getBaseLink($id_shop, null, $relative_protocol) . $this->getLangLink($id_lang, null, $id_shop);
     if (!is_object($product)) {
         if (is_array($product) && isset($product['id_product'])) {
             $product = new Product($product['id_product'], false, $id_lang, $id_shop);
         } elseif ((int) $product) {
             $product = new Product((int) $product, false, $id_lang, $id_shop);
         } else {
             throw new PrestaShopException('Invalid product vars');
         }
     }
     // Set available keywords
     $params = array();
     $params['id'] = $product->id;
     $params['rewrite'] = !$alias ? $product->getFieldByLang('link_rewrite') : $alias;
     $params['ean13'] = !$ean13 ? $product->ean13 : $ean13;
     $params['meta_keywords'] = Tools::str2url($product->getFieldByLang('meta_keywords'));
     $params['meta_title'] = Tools::str2url($product->getFieldByLang('meta_title'));
     if ($dispatcher->hasKeyword('product_rule', $id_lang, 'manufacturer', $id_shop)) {
         $params['manufacturer'] = Tools::str2url($product->isFullyLoaded ? $product->manufacturer_name : Manufacturer::getNameById($product->id_manufacturer));
     }
     if ($dispatcher->hasKeyword('product_rule', $id_lang, 'supplier', $id_shop)) {
         $params['supplier'] = Tools::str2url($product->isFullyLoaded ? $product->supplier_name : Supplier::getNameById($product->id_supplier));
     }
     if ($dispatcher->hasKeyword('product_rule', $id_lang, 'price', $id_shop)) {
         $params['price'] = $product->isFullyLoaded ? $product->price : Product::getPriceStatic($product->id, false, null, 6, null, false, true, 1, false, null, null, null, $product->specificPrice);
     }
     if ($dispatcher->hasKeyword('product_rule', $id_lang, 'tags', $id_shop)) {
         $params['tags'] = Tools::str2url($product->getTags($id_lang));
     }
     if ($dispatcher->hasKeyword('product_rule', $id_lang, 'category', $id_shop)) {
         $params['category'] = !is_null($product->category) && !empty($product->category) ? Tools::str2url($product->category) : Tools::str2url($category);
     }
     if ($dispatcher->hasKeyword('product_rule', $id_lang, 'reference', $id_shop)) {
         $params['reference'] = Tools::str2url($product->reference);
     }
     if ($dispatcher->hasKeyword('product_rule', $id_lang, 'categories', $id_shop)) {
         $params['category'] = !$category ? $product->category : $category;
         $cats = array();
         foreach ($product->getParentCategories($id_lang) as $cat) {
             if (!in_array($cat['id_category'], Link::$category_disable_rewrite)) {
                 //remove root and home category from the URL
                 $cats[] = $cat['link_rewrite'];
             }
         }
         $params['categories'] = implode('/', $cats);
     }
     $anchor = $ipa ? $product->getAnchor((int) $ipa, (bool) $add_anchor) : '';
     return $url . $dispatcher->createUrl('product_rule', $id_lang, $params, $force_routes, $anchor, $id_shop);
 }
 /**
  * @return mixed
  */
 public function renderForm()
 {
     if (($obj = $this->loadObject(true)) && Validate::isLoadedObject($obj)) {
         $link = $obj->getImageLink();
         if (file_exists($obj->getImageLink(_PS_IMG_DIR_))) {
             $size = round(filesize($obj->getImageLink(_PS_IMG_DIR_)) / 1024);
         }
     }
     $this->fields_form = array('legend' => array('title' => $this->module->l('Block Slideshow', 'AdminNowSlideshow'), 'icon' => 'icon-list-alt'), 'input' => array(array('type' => 'text', 'label' => $this->module->l('Name', 'AdminNowSlideshow'), 'name' => 'name', 'required' => true, 'lang' => true), array('type' => 'text', 'label' => $this->module->l('Title', 'AdminNowSlideshow'), 'name' => 'title', 'required' => true, 'lang' => true), array('type' => 'text', 'label' => $this->module->l('Button name', 'AdminNowSlideshow'), 'name' => 'button_name', 'required' => true, 'lang' => true), array('type' => 'textarea', 'label' => $this->module->l('Description', 'AdminNowSlideshow'), 'name' => 'description', 'required' => true, 'lang' => true, 'autoload_rte' => true), array('type' => 'select', 'label' => $this->module->l('Type of link', 'AdminNowSlideshow'), 'name' => 'type', 'required' => true, 'default_value' => NowSlideshow::TYPE_LINK, 'options' => array('query' => array(array('id_type' => NowSlideshow::TYPE_CATEGORY, 'type' => $this->module->l('Category', 'AdminNowSlideshow')), array('id_type' => NowSlideshow::TYPE_CMS, 'type' => $this->module->l('CMS', 'AdminNowSlideshow')), array('id_type' => NowSlideshow::TYPE_LINK, 'type' => $this->module->l('Link', 'AdminNowSlideshow')), array('id_type' => NowSlideshow::TYPE_MANUFACTURER, 'type' => $this->module->l('Manufacturer', 'AdminNowSlideshow'))), 'id' => 'id_type', 'name' => 'type')), array('type' => 'text', 'label' => $this->module->l('ID type', 'AdminNowSlideshow'), 'name' => 'id_type', 'form_group_class' => 'idTypeDiv'), array('type' => 'categories', 'label' => $this->l('Category'), 'name' => 'category', 'tree' => array('id' => 'categories-tree'), 'form_group_class' => 'categoryDiv'), array('type' => 'select', 'label' => $this->module->l('CMS', 'AdminNowSlideshow'), 'name' => 'cms', 'options' => array('query' => CMS::listCms($this->context->language->id), 'id' => 'id_cms', 'name' => 'meta_title'), 'form_group_class' => 'cmsDiv'), array('type' => 'select', 'label' => $this->module->l('Manufacturer', 'AdminNowSlideshow'), 'name' => 'manufacturer', 'options' => array('query' => Manufacturer::getManufacturers(false, $this->context->language->id), 'id' => 'id_manufacturer', 'name' => 'name'), 'form_group_class' => 'manufacturerDiv'), array('type' => 'text', 'label' => $this->module->l('Link', 'AdminNowSlideshow'), 'name' => 'link', 'form_group_class' => 'linkDiv', 'lang' => true), array('type' => 'file', 'label' => $this->module->l('Image (.png)', 'AdminNowSlideshow'), 'name' => 'image', 'display_image' => true, 'show_thumbnail' => true, 'image' => isset($link) ? '<img src="' . $link . '"/>' : null, 'size' => isset($size) ? $size : null), array('type' => 'switch', 'label' => $this->module->l('Enable', 'AdminNowSlideshow'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->module->l('Enabled', 'AdminNowSlideshow')), array('id' => 'active_off', 'value' => 0, 'label' => $this->module->l('Disabled', 'AdminNowSlideshow'))))), 'submit' => array('title' => $this->module->l('Save', 'AdminNowSlideshow')));
     return parent::renderForm();
 }
 public function run()
 {
     $date = date("Y-m-d");
     $manufacturers[] = array('name' => 'Apple', 'created_at' => $date, 'user_id' => 1, 'updated_at' => $date, 'deleted_at' => NULL);
     $manufacturers[] = array('name' => 'Microsoft', 'created_at' => $date, 'user_id' => 1, 'updated_at' => $date, 'deleted_at' => NULL);
     $manufacturers[] = array('name' => 'ASUS', 'created_at' => $date, 'user_id' => 1, 'updated_at' => $date, 'deleted_at' => NULL);
     $manufacturers[] = array('name' => 'Dell', 'created_at' => $date, 'user_id' => 1, 'updated_at' => $date, 'deleted_at' => NULL);
     // Delete all the blog posts
     DB::table('manufacturers')->truncate();
     // Insert the blog posts
     Manufacturer::insert($manufacturers);
 }
 static function create($record = null)
 {
     if (Manufacturer::haveProducts($record->id)) {
         if (!Model::factory('Manufacturer')->find_one($record->id)) {
             Model::factory('Manufacturer')->create(array('manufacturer_id' => $record->id, 'name' => $record->name, 'image' => $record->image))->save();
             Model::factory('ManufacturerDescription')->create(array('manufacturer_id' => $record->id, 'language_id' => 1, 'description' => $record->description_full, 'meta_description' => $record->description, 'meta_keyword' => $record->name, 'seo_title' => $record->name, 'seo_h1' => $record->name))->save();
             Model::factory('ManufacturerToStore')->create(array('manufacturer_id' => $record->id, 'store_id' => 0))->save();
             return true;
         }
     }
     return false;
 }
Example #18
0
 /**
  * @since version 0.84
  *
  * @see CommonDevice::getHTMLTableCellForItem()
  **/
 function getHTMLTableCellForItem(HTMLTableRow $row = NULL, CommonDBTM $item = NULL, HTMLTableCell $father = NULL, array $options = array())
 {
     $column = parent::getHTMLTableCellForItem($row, $item, $father, $options);
     if ($column == $father) {
         return $father;
     }
     switch ($item->getType()) {
         case 'Computer':
             Manufacturer::getHTMLTableCellsForItem($row, $this, NULL, $options);
             break;
     }
 }
Example #19
0
 public function save()
 {
     $manufacturer = Manufacturer::model()->findByPk($this->id);
     if (is_null($manufacturer)) {
         // is insert
         $manufacturer = new Manufacturer();
     }
     $manufacturer->name = $this->name;
     $manufacturer->image = $this->image;
     $manufacturer->sort_order = $this->sortOrder;
     $manufacturer->save();
     // SEO Keyword
     $manufacturer->updateSEOKeyword($this->seoKeyword);
     // Stores
     $manufacturer->clearAllStoresRelations();
     if (isset($this->stores) && count($this->stores)) {
         foreach ($this->stores as $storeId) {
             $manufacturer->addToStore($storeId);
         }
     }
 }
Example #20
0
 /**
  * Delete several objects from database
  *
  * return boolean Deletion result
  */
 public function deleteSelection($selection)
 {
     if (!is_array($selection)) {
         die(Tools::displayError());
     }
     $result = true;
     foreach ($selection as $id) {
         $this->id = (int) $id;
         $this->id_address = Manufacturer::getManufacturerAddress();
         $result = $result && $this->delete();
     }
     return $result;
 }
Example #21
0
 public function hookdisplayGroupSports($params)
 {
     if (!$this->isCached('brandsslider.tpl', $this->getCacheId())) {
         $manufacturers = Manufacturer::getManufacturers();
         foreach ($manufacturers as $key => $item) {
             foreach ($manufacturers as &$item) {
                 $item['image'] = $item['id_manufacturer'] . '-brand-136x69.jpg';
             }
         }
         $this->smarty->assign('manufacturers', $manufacturers);
     }
     return $this->display(__FILE__, 'brandsslider.tpl', $this->getCacheId());
 }
Example #22
0
 public function hookLeftColumn($params)
 {
     if (!$this->isCached('blockmanufacturer.tpl', $this->getCacheId())) {
         $manufacturers = Manufacturer::getManufacturers();
         foreach ($manufacturers as &$manufacturer) {
             $manufacturer['image'] = $this->context->language->iso_code . '-default';
             if (file_exists(_PS_MANU_IMG_DIR_ . $manufacturer['id_manufacturer'] . '-' . ImageType::getFormatedName('medium') . '.jpg')) {
                 $manufacturer['image'] = $manufacturer['id_manufacturer'];
             }
         }
         $this->smarty->assign(array('manufacturers' => $manufacturers, 'text_list' => Configuration::get('MANUFACTURER_DISPLAY_TEXT'), 'text_list_nb' => Configuration::get('MANUFACTURER_DISPLAY_TEXT_NB'), 'form_list' => Configuration::get('MANUFACTURER_DISPLAY_FORM'), 'display_link_manufacturer' => Configuration::get('PS_DISPLAY_SUPPLIERS')));
     }
     return $this->display(__FILE__, 'blockmanufacturer.tpl', $this->getCacheId());
 }
Example #23
0
 public function renderContent($setting)
 {
     $t = array('name' => '', 'html' => '');
     $setting = array_merge($t, $setting);
     $data = Manufacturer::getManufacturers(false, 0, true, 1, $setting['limit']);
     foreach ($data as $key => $item) {
         $item['image'] = !file_exists(_PS_MANU_IMG_DIR_ . $item['id_manufacturer'] . '-' . ImageType::getFormatedName('medium') . '.jpg') ? Context::getContext()->language->iso_code . '-default' : $item['id_manufacturer'];
         $data[$key] = $item;
     }
     $setting['manufacturers'] = $data;
     $setting['link'] = Context::getContext()->link;
     $output = array('type' => 'manufacture', 'data' => $setting);
     return $output;
 }
 public function hookDisplayHome($params)
 {
     if (!$this->isCached('tmbrandlogo.tpl', $this->getCacheId())) {
         $manufacturers = Manufacturer::getManufacturers();
         foreach ($manufacturers as &$manufacturer) {
             $manufacturer['image'] = $this->context->language->iso_code . '-default';
             if (file_exists(_PS_MANU_IMG_DIR_ . $manufacturer['id_manufacturer'] . '-' . ImageType::getFormatedName('medium') . '.jpg')) {
                 $manufacturer['image'] = $manufacturer['id_manufacturer'];
             }
         }
         $this->smarty->assign(array('manufacturers' => $manufacturers, 'tm_slider' => Configuration::get('TM_BRAND_SLIDER'), 'tm_logoname' => Configuration::get('TM_BRAND_NAME'), 'display_link_manufacturer' => Configuration::get('PS_DISPLAY_SUPPLIERS')));
     }
     return $this->display(__FILE__, 'tmbrandlogo.tpl', $this->getCacheId());
 }
Example #25
0
 public function renderContent($args, $setting)
 {
     $t = array('name' => '', 'html' => '');
     $setting = array_merge($t, $setting);
     $plimit = $setting['limit'] ? (int) $setting['limit'] : 10;
     $image_type = $setting['image'] ? $setting['image'] : 'small' . '_default';
     $data = Manufacturer::getManufacturers(true, Context::getContext()->language->id, true, 1, $plimit, false);
     foreach ($data as &$item) {
         $id_images = !file_exists(_PS_MANU_IMG_DIR_ . '/' . $item['id_manufacturer'] . '-' . $image_type . '.jpg') ? Language::getIsoById(Context::getContext()->language->id) . '-default' : $item['id_manufacturer'];
         $item['image'] = _THEME_MANU_DIR_ . $id_images . '-' . $image_type . '.jpg';
     }
     $setting['manufacturers'] = $data;
     $output = array('type' => 'manufacture', 'data' => $setting);
     return $output;
 }
 /**
  * @since version 0.84
  *
  * @see CommonDevice::getHTMLTableCellForItem()
  **/
 function getHTMLTableCellForItem(HTMLTableRow $row = NULL, CommonDBTM $item = NULL, HTMLTableCell $father = NULL, array $options = array())
 {
     $column = parent::getHTMLTableCellForItem($row, $item, $father, $options);
     if ($column == $father) {
         return $father;
     }
     switch ($item->getType()) {
         case 'Computer':
             Manufacturer::getHTMLTableCellsForItem($row, $this, NULL, $options);
             if ($this->fields["assettag"]) {
                 $row->addCell($row->getHeaderByName('devicebiosdata_tag'), Dropdown::getYesNo($this->fields["assettag"]), $father);
             }
             if ($this->fields["date"]) {
                 $row->addCell($row->getHeaderByName('devicebiosdata_date'), $this->fields["date"], $father);
             }
     }
 }
Example #27
0
 /**
  * Assign template vars if displaying the manufacturer list
  */
 protected function assignAll()
 {
     if (Configuration::get('PS_DISPLAY_SUPPLIERS')) {
         $data = Manufacturer::getManufacturers(false, $this->context->language->id, true, false, false, false);
         $nbProducts = count($data);
         $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
         $this->p = abs((int) Tools::getValue('p', 1));
         $data = Manufacturer::getManufacturers(true, $this->context->language->id, true, $this->p, $this->n, false);
         $this->pagination($nbProducts);
         foreach ($data as &$item) {
             $item['image'] = !file_exists(_PS_MANU_IMG_DIR_ . $item['id_manufacturer'] . '-' . ImageType::getFormatedName('medium') . '.jpg') ? $this->context->language->iso_code . '-default' : $item['id_manufacturer'];
         }
         $this->context->smarty->assign(array('pages_nb' => ceil($nbProducts / (int) $this->n), 'nbManufacturers' => $nbProducts, 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'manufacturers' => $data, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY')));
     } else {
         $this->context->smarty->assign('nbManufacturers', 0);
     }
 }
 protected function SetupManufacturer()
 {
     // Lookup Object PK information from Query String (if applicable)
     // Set mode to Edit or New depending on what's found
     $intManufacturerId = QApplication::QueryString('intManufacturerId');
     if ($intManufacturerId) {
         $this->objManufacturer = Manufacturer::Load($intManufacturerId);
         if (!$this->objManufacturer) {
             throw new Exception('Could not find a Manufacturer object with PK arguments: ' . $intManufacturerId);
         }
         $this->strTitleVerb = QApplication::Translate('Edit');
         $this->blnEditMode = true;
     } else {
         $this->objManufacturer = new Manufacturer();
         $this->strTitleVerb = QApplication::Translate('Create');
         $this->blnEditMode = false;
     }
 }
Example #29
0
 public function renderContent($setting)
 {
     $t = array('name' => '', 'html' => '', 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1, 'widgetid' => 'manu-' . time());
     $setting = array_merge($t, $setting);
     $manufacturers = Manufacturer::getManufacturers();
     foreach ($manufacturers as &$manufacturer) {
         $manufacturer['image'] = Context::getContext()->language->iso_code . '-default';
         if (file_exists(_PS_MANU_IMG_DIR_ . $manufacturer['id_manufacturer'] . '-' . ImageType::getFormatedName('medium') . '.jpg')) {
             $manufacturer['image'] = $manufacturer['id_manufacturer'];
         }
     }
     $setting['manufacturers'] = $manufacturers;
     $list_mode_tpl = _PS_MODULE_DIR_ . '/pspagebuilder/views/templates/front/widgets/sub/item_manufacturer_' . $setting['list_mode'] . '.tpl';
     $tlist_mode_tpl = _PS_ALL_THEMES_DIR_ . _THEME_NAME_ . '/modules/pspagebuilder/views/templates/front/widgets/sub/item_manufacturer_' . $setting['list_mode'] . '.tpl';
     if (file_exists($tlist_mode_tpl)) {
         $list_mode_tpl = $tlist_mode_tpl;
     }
     $setting['list_mode_tpl'] = $list_mode_tpl;
     $output = array('type' => 'manufacturer', 'data' => $setting);
     return $output;
 }
 public function process()
 {
     if (Validate::isLoadedObject($this->manufacturer) and $this->manufacturer->active) {
         $nbProducts = $this->manufacturer->getProducts($this->manufacturer->id, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
         $this->pagination($nbProducts);
         self::$smarty->assign(array('nb_products' => $nbProducts, 'products' => $this->manufacturer->getProducts($this->manufacturer->id, (int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay), 'path' => $this->manufacturer->active ? Tools::safeOutput($this->manufacturer->name) : '', 'manufacturer' => $this->manufacturer));
     } elseif (!Tools::getValue('id_manufacturer')) {
         if (Configuration::get('PS_DISPLAY_SUPPLIERS')) {
             $result = Manufacturer::getManufacturers(true, (int) self::$cookie->id_lang, true);
             $nbProducts = count($result);
             $this->pagination($nbProducts);
             $manufacturers = Manufacturer::getManufacturers(true, (int) self::$cookie->id_lang, true, $this->p, $this->n);
             foreach ($manufacturers as &$row) {
                 $row['image'] = !file_exists(_PS_MANU_IMG_DIR_ . '/' . $row['id_manufacturer'] . '-medium.jpg') ? Language::getIsoById((int) self::$cookie->id_lang) . '-default' : $row['id_manufacturer'];
             }
             self::$smarty->assign(array('pages_nb' => ceil($nbProducts / (int) $this->n), 'nbManufacturers' => $nbProducts, 'mediumSize' => Image::getSize('medium'), 'manufacturers' => $manufacturers, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY')));
         } else {
             self::$smarty->assign('nbManufacturers', 0);
         }
     }
 }