Jump to content

Search the Community

Showing results for tags 'prestashop 1.7 widget'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Community Help and Support
    • PrestaShop Download
    • PrestaShop Marketplace
  • News and Announcements
    • PrestaShop news and releases
    • PrestaShop Beta
    • PrestaShop Blogs
    • PrestaShop Meetups
  • International community (English)
    • General topics
    • PrestaShop Merchants
    • PrestaShop Developers
    • Taxes, Translations & Laws
    • Community Modules and Themes
  • Forum francophone
    • Discussion générale
    • Aide et support communautaire
    • PrestaShop pour les marchands
    • PrestaShop pour les développeurs
    • Adaptation aux lois Québécoises
    • Modules et thèmes gratuits
    • Modules et thèmes payants
  • Foro en Español
    • Discusión general
    • Soporte de la comunidad y ayuda
    • Comerciantes PrestaShop
    • Desarrolladores PrestaShop
    • Módulos y plantillas gratuitas
  • Forum italiano
    • Forum generale
    • Aiuto e supporto della Community
    • Commercianti PrestaShop
    • Sviluppatori PrestaShop
    • Aspetti legali sull'eCommerce
    • Moduli e template gratuiti
  • Deutsches Forum
    • Generelle Fragen
    • Support und Hilfe aus der Community
    • e-Commerce/Versand-Handel mit Prestashop
    • Prestashop-Entwickler
    • Anpassung an deutsches Recht
    • Kostenlose Module und Templates
    • Generelle Fragen Copy
  • Nederlandstalig forum
    • Algemeen
    • Hulp en ondersteuning, van en voor de community
    • PrestaShop-winkeliers
    • PrestaShop-ontwikkelaars
    • Het aanpassen van PrestaShop
    • Gratis modules en templates
  • Fórum em Português
    • Fórum Geral
    • Ajuda e Suporte da Comunidade
    • Lojistas que utilizam o PrestaShop
    • Desenvolvedores PrestaShop
    • Legislação específica
    • Módulos e temas gratuitos
  • Polskie forum
    • Forum ogólne
    • Wsparcie i pomoc użytkowników
    • Oferty twórców PrestaShop
    • Deweloperzy PrestaShop
    • Darmowe Moduły i Szablony
  • Dansk forum
    • Generelt forum
    • Hjælp og support fra fællesskabet
    • PrestaShop for købmænd
    • PrestaShop for udviklere
    • Love og regler
    • Gratis moduler og temaer
  • České fórum
    • Instalasi, Konfigurasi dan upgrade
    • Obecná diskuze
    • Bezplatné moduly a šablony
    • PrestaShop vývojáři
    • PrestaShop obchodníci
  • Bahasa Indonesia
    • Diskusi Umum
    • Podpora a pomoc komunity
    • Laporan Bug
    • Jasa, Promosi & Lowongan Kerja
  • Svenskt forum
    • Allmän diskussion
    • Installation, konfigurering och uppdatering
  • Forumul românesc
    • Discuţii generale
    • Instalare, configurare şi upgrade
  • Pусский язык
    • Обсуждение скрипта
    • Установка, Настройка, Обновление
    • Прием багов
  • Slovenské fórum
    • Všeobecná diskusia
    • Podpora a pomoc komunity
    • PrestaShop obchodníci
    • PrestaShop vývojári
    • Bezplatné moduly a šablóny
  • Türkçe Topluluğu
    • Genel Konular
    • Topluluk desteği ve yardım
    • PrestaShop Tüccarları
    • Prestashop Geliştiricileri
    • Ücretsiz Modül ve Temalar
  • Diễn đàn tiếng Việt
    • Thảo luận chung
    • Hỗ trợ từ cộng đồng
    • Dành cho chủ doanh nghiệp / cửa hàng
    • Dành cho lập trình viên
  • PrestaShop Communities
    • اللغه العربيه [Arabic]
    • Ελληνικά [Greek]
    • עִבְרִית [Hebrew]
    • 中文
    • Magyar [Hungarian]
    • 日本語 [Japanese]
    • Lietuviškai [Lithuanian]
    • انجمن فارسی [Persian]
    • ไทย [Thai]
    • Malaysia [Malaysian]
    • Eesti [Estonian]
    • Slovenščina [Slovenian]
    • Српски [Serbian]
  • IP. Board Forum
    • IP. Board Forum Questions and Issues
  • Archive
    • Zapłać Moduły i Szablony [ARCHIVE]
    • Moduly, upravy a dizajn [ARCHIVE]
    • Phát triển và các mô-đun [ARCHIVE]
    • Yazılım, Modül ve Tema [ARCHIVE]
    • Модули, Шаблоны [ARCHIVE]
    • Module şi teme [ARCHIVE]
    • Pengembangan dan Modul [ARCHIVE]
    • Moduler och teman [ARCHIVE]
    • Ecommerce x PrestaShop [ARCHIVE BOARD]
    • Vývoj a moduly [ARCHIVE]
    • Kostenpflichtige Module, Templates [ARCHIVE]
    • Módulos y temas pagos [ARCHIVE]
    • Módulos e temas pagos [ARCHIVE]
    • Servizi commerciali [ARCHIVE]
    • Forum - Feedback Contributor
    • PrestaShop Cloud

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. Bonjour, tout nouveau sur prestashop j'essais d'utiliser les widget pour mon module. j'ai donc ma structure de module (module generator ). puis j'ai ma classe qui etend modules et implement WidgetInterface le module est installé correctement quand je vais dans position je le vois bien dans le displayHome, mais la methode renderWidget n'est jamais appelée. dans le code que je test j'ai fait une copie des methode du module Ps_FeaturedProducts qui utilise widget mais rien ne s'affiche.. par contre si j'utilise le hook home alors je peux afficher ??? <?php /** * 2007-2017 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2017 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_PS_VERSION_')) { exit; } use PrestaShop\PrestaShop\Core\Module\WidgetInterface; use PrestaShop\PrestaShop\Adapter\Category\CategoryProductSearchProvider; use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever; use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter; use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter; use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever; use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; use PrestaShop\PrestaShop\Core\Product\Search\SortOrder; class FidintMarket extends Module implements WidgetInterface { protected $config_form = false; public function __construct() { $this->name = 'fidintmarket'; $this->tab = 'market_place'; $this->version = '1.0.0'; $this->author = 'Fid-Int'; $this->need_instance = 0; /** * Set $this->bootstrap to true if your module is compliant with bootstrap (PrestaShop 1.6) */ $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('FID-INT Market'); $this->description = $this->l('Market place FID-INT pour petits commerçants'); $this->confirmUninstall = $this->l('êtes-vous certain de désactiver FID-INT market place'); $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); //$this->templateFile = 'module:ps_featuredproducts/views/templates/hook/ps_featuredproducts.tpl'; $this->templateFile = 'module:FidintMarket/views/templates/hook/test.tpl'; } /** * Don't forget to create update methods if needed: * http://doc.prestashop.com/display/PS16/Enabling+the+Auto-Update */ public function install() { Configuration::updateValue('FIDINTMARKET_LIVE_MODE', false); include(dirname(__FILE__).'/sql/install.php'); return parent::install() && $this->registerHook('header') && $this->registerHook('backOfficeHeader') && $this->registerHook('displayHome') && $this->registerHook('displayRightColumnProduct'); } public function uninstall() { Configuration::deleteByName('FIDINTMARKET_LIVE_MODE'); include(dirname(__FILE__).'/sql/uninstall.php'); return parent::uninstall(); } /** * Create the structure of your form. */ protected function getConfigForm() { return array( 'form' => array( 'legend' => array( 'title' => $this->l('Settings'), 'icon' => 'icon-cogs', ), 'input' => array( array( 'type' => 'switch', 'label' => $this->l('Live mode'), 'name' => 'FIDINTMARKET_LIVE_MODE', 'is_bool' => true, 'desc' => $this->l('Use this module in live mode'), 'values' => array( array( 'id' => 'active_on', 'value' => true, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => false, 'label' => $this->l('Disabled') ) ), ), array( 'col' => 3, 'type' => 'text', 'prefix' => '<i class="icon icon-envelope"></i>', 'desc' => $this->l('Enter a valid email address'), 'name' => 'FIDINTMARKET_ACCOUNT_EMAIL', 'label' => $this->l('Email'), ), array( 'type' => 'password', 'name' => 'FIDINTMARKET_ACCOUNT_PASSWORD', 'label' => $this->l('Password'), ), ), 'submit' => array( 'title' => $this->l('Save'), ), ), ); } /** * Set values for the inputs. */ protected function getConfigFormValues() { return array( 'FIDINTMARKET_LIVE_MODE' => Configuration::get('FIDINTMARKET_LIVE_MODE', true), 'FIDINTMARKET_ACCOUNT_EMAIL' => Configuration::get('FIDINTMARKET_ACCOUNT_EMAIL', '[email protected]'), 'FIDINTMARKET_ACCOUNT_PASSWORD' => Configuration::get('FIDINTMARKET_ACCOUNT_PASSWORD', null), ); } /** * Save form data. */ protected function postProcess() { $form_values = $this->getConfigFormValues(); foreach (array_keys($form_values) as $key) { Configuration::updateValue($key, Tools::getValue($key)); } } /** * Add the CSS & JavaScript files you want to be loaded in the BO. */ public function hookBackOfficeHeader() { if (Tools::getValue('module_name') == $this->name) { $this->context->controller->addJS($this->_path.'views/js/back.js'); $this->context->controller->addCSS($this->_path.'views/css/back.css'); } } /** * Add the CSS & JavaScript files you want to be added on the FO. */ public function hookHeader() { $this->context->controller->addJS($this->_path.'/views/js/front.js'); $this->context->controller->addCSS($this->_path.'/views/css/front.css'); } public function hookDisplayHome() { } public function hookDisplayRightColumnProduct() { /* Place your code here. */ } /** * Load the configuration form */ public function getContent() { $output = ''; $errors = array(); if (Tools::isSubmit('submitHomeFeatured')) { $nbr = Tools::getValue('HOME_FEATURED_NBR'); if (!Validate::isInt($nbr) || $nbr <= 0) { $errors[] = $this->trans('The number of products is invalid. Please enter a positive number.', array(), 'Modules.FeaturedProducts.Admin'); } $cat = Tools::getValue('HOME_FEATURED_CAT'); if (!Validate::isInt($cat) || $cat <= 0) { $errors[] = $this->trans('The category ID is invalid. Please choose an existing category ID.', array(), 'Modules.FeaturedProducts.Admin'); } $rand = Tools::getValue('HOME_FEATURED_RANDOMIZE'); if (!Validate::isBool($rand)) { $errors[] = $this->trans('Invalid value for the "randomize" flag.', array(), 'Modules.FeaturedProducts.Admin'); } if (isset($errors) && count($errors)) { $output = $this->displayError(implode('<br />', $errors)); } else { Configuration::updateValue('HOME_FEATURED_NBR', (int) $nbr); Configuration::updateValue('HOME_FEATURED_CAT', (int) $cat); Configuration::updateValue('HOME_FEATURED_RANDOMIZE', (bool) $rand); $this->_clearCache('*'); $output = $this->displayConfirmation($this->trans('The settings have been updated.', array(), 'Admin.Notifications.Success')); } } return $output.$this->renderForm(); } /** * Create the form that will be displayed in the configuration of your module. */ public function renderForm() { $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->trans('Settings', array(), 'Admin.Global'), 'icon' => 'icon-cogs', ), 'description' => $this->trans('To add products to your homepage, simply add them to the corresponding product category (default: "Home").', array(), 'Modules.FeaturedProducts.Admin'), 'input' => array( array( 'type' => 'text', 'label' => $this->trans('Number of products to be displayed', array(), 'Modules.FeaturedProducts.Admin'), 'name' => 'HOME_FEATURED_NBR', 'class' => 'fixed-width-xs', 'desc' => $this->trans('Set the number of products that you would like to display on homepage (default: 8).', array(), 'Modules.FeaturedProducts.Admin'), ), array( 'type' => 'text', 'label' => $this->trans('Category from which to pick products to be displayed', array(), 'Modules.FeaturedProducts.Admin'), 'name' => 'HOME_FEATURED_CAT', 'class' => 'fixed-width-xs', 'desc' => $this->trans('Choose the category ID of the products that you would like to display on homepage (default: 2 for "Home").', array(), 'Modules.FeaturedProducts.Admin'), ), array( 'type' => 'switch', 'label' => $this->trans('Randomly display featured products', array(), 'Modules.FeaturedProducts.Admin'), 'name' => 'HOME_FEATURED_RANDOMIZE', 'class' => 'fixed-width-xs', 'desc' => $this->trans('Enable if you wish the products to be displayed randomly (default: no).', array(), 'Modules.FeaturedProducts.Admin'), 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->trans('Yes', array(), 'Admin.Global'), ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->trans('No', array(), 'Admin.Global'), ), ), ), ), 'submit' => array( 'title' => $this->trans('Save', array(), 'Admin.Actions'), ), ), ); $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $helper = new HelperForm(); $helper->show_toolbar = false; $helper->table = $this->table; $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->id = (int) Tools::getValue('id_carrier'); $helper->identifier = $this->identifier; $helper->submit_action = 'submitHomeFeatured'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array( 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id, ); return $helper->generateForm(array($fields_form)); } public function getConfigFieldsValues() { return array( 'HOME_FEATURED_NBR' => Tools::getValue('HOME_FEATURED_NBR', (int) Configuration::get('HOME_FEATURED_NBR')), 'HOME_FEATURED_CAT' => Tools::getValue('HOME_FEATURED_CAT', (int) Configuration::get('HOME_FEATURED_CAT')), 'HOME_FEATURED_RANDOMIZE' => Tools::getValue('HOME_FEATURED_RANDOMIZE', (bool) Configuration::get('HOME_FEATURED_RANDOMIZE')), ); } public function renderWidget($hookName = null, array $configuration = []) { echo "render widget"; /*if (!$this->isCached($this->templateFile, $this->getCacheId('fidintmarket'))) { $variables = $this->getWidgetVariables($hookName, $configuration); if (empty($variables)) { return false; } $this->smarty->assign($variables); }*/ return $this->fetch($this->templateFile, $this->getCacheId('fidintmarket')); } public function getWidgetVariables($hookName = null, array $configuration = []) { $products = $this->getProducts(); if (!empty($products)) { return array( 'products' => $products, 'allProductsLink' => Context::getContext()->link->getCategoryLink($this->getConfigFieldsValues()['HOME_FEATURED_CAT']), ); } return false; } protected function getProducts() { $category = new Category((int) Configuration::get('HOME_FEATURED_CAT')); $searchProvider = new CategoryProductSearchProvider( $this->context->getTranslator(), $category ); $context = new ProductSearchContext($this->context); $query = new ProductSearchQuery(); $nProducts = Configuration::get('HOME_FEATURED_NBR'); if ($nProducts < 0) { $nProducts = 12; } $query ->setResultsPerPage($nProducts) ->setPage(1) ; if (Configuration::get('HOME_FEATURED_RANDOMIZE')) { $query->setSortOrder(SortOrder::random()); } else { $query->setSortOrder(new SortOrder('product', 'position', 'asc')); } $result = $searchProvider->runQuery( $context, $query ); $assembler = new ProductAssembler($this->context); $presenterFactory = new ProductPresenterFactory($this->context); $presentationSettings = $presenterFactory->getPresentationSettings(); $presenter = new ProductListingPresenter( new ImageRetriever( $this->context->link ), $this->context->link, new PriceFormatter(), new ProductColorsRetriever(), $this->context->getTranslator() ); $products_for_template = []; foreach ($result->getProducts() as $rawProduct) { $products_for_template[] = $presenter->present( $presentationSettings, $assembler->assembleProduct($rawProduct), $this->context->language ); } //print_r($products_for_template); return $products_for_template; } } merci pour votre coup de main.
×
×
  • Create New...