Jump to content

infortecstore

Members
  • Posts

    29
  • Joined

  • Last visited

Contact Methods

Profile Information

  • Location
    Italia
  • Activity
    Agency

Recent Profile Visitors

493 profile views

infortecstore's Achievements

Newbie

Newbie (1/14)

1

Reputation

  1. Utilizzo UwAmp e la versione del php è la 7.0.3. ora sto caricando tutto in remoto per vedere se è un problema di webserver.
  2. Salve, ho installato prestashop 1.7.4.2 in locale, tema base, quando clicco su aggiungi al carrello non succede nulla, se aggiorno la pagina il carrello visualizza il prodotto mentre se non aggiorno e clicco di nuovo su aggiungi al carrello si inseriscono 2 prodotti. Da cosa può dipendere?
  3. Nessuno sa darmi un consiglio? Si può! Non si può! Cosa modificare!
  4. Ho travato questo codice che assegna i corrieri in base alla categorie, vorrei modificarlo per assegnare i corrieri in base al fornitore. Cosa devo sostituire? <?php if (!defined('_PS_VERSION_')) exit; class carrierAssigner extends Module { protected $_errors = array(); protected $_html = ''; public function __construct() { $this->name = 'carrierassigner'; $this->tab = 'administration'; $this->version = '1.0'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Carrier Assigner'); $this->description = $this->l('Assign carriers to products in bulk.'); } public function install() { if (!parent::install()) return false; return true; } public function uninstall() { if (!parent::uninstall()) return false; return true; } private function _installConfig() { foreach ($this->_config as $keyname => $value) { Configuration::updateValue($keyname, $value); } return true; } private function _eraseConfig() { foreach ($this->_config as $keyname => $value) { Configuration::deleteByName($keyname); } return true; } public function getContent() { $this->_postProcess(); $this->_displayForm(); return $this->_html; } private function _displayForm() { $this->_html .= $this->_generateForm(); // With Template $this->context->smarty->assign(array( 'variable'=> 1 )); $this->_html .= $this->display(__FILE__, 'backoffice.tpl'); } private function _generateForm() { $inputs = array(); $inputs[] = array( 'type' => 'radio', 'label' => $this->l('Method'), 'name' => 'assign_method', 'desc' => $this->l('Choose which method to use to assign products below'), 'values' => array( array( 'id' => 'method_input', 'value' => 0, 'label' => $this->l('Text input') ), array( 'id' => 'method_category', 'value' => 1, 'label' => $this->l('By Category Selection') ) ), ); $inputs[] = array( 'type' => 'text', 'label' => $this->l('Products IDs'), 'name' => 'product_ids', 'desc' => $this->l('Add the product ids you want to assign the carrier to, separated by comma. Leave blank if you choose to assign by category') ); $inputs[] = array( 'type' => 'categories', 'label' => $this->l('By category'), 'name' => 'assign_categories', 'desc' => $this->l('Select the category of which products will be bound to the chosen carrier'), 'tree' => array( 'root_category' => 1, 'id' => 'id_category', 'name' => 'name_category', 'selected_categories' => array(), ) ); $carriers = Carrier::getCarriers($this->context->language->id); // only get active ones $inputs[] = array( 'type' => 'select', 'label' => $this->l('Carrier'), 'name' => 'chosen_carrier', 'desc' => 'Select the carrier you want to bind to these products', 'options' => array( 'query' => $carriers, 'id' => 'id_reference', 'name' => 'name' ), ); $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('Settings'), 'icon' => 'icon-cogs' ), 'description' => $this->l('Use this form to bind products to any chosen carrier. If any of them is bound already, the module will just ignore it.'), 'input' => $inputs, 'submit' => array( 'title' => $this->l('Assign'), 'class' => 'btn btn-default pull-right', 'name' => 'submitUpdate' ) ) ); $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $helper = new HelperForm(); $helper->default_form_language = $lang->id; // $helper->submit_action = 'submitUpdate'; $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' => array('assign_method' => 0, 'product_ids' => '', 'chosen_carrier' => '0' ) ); return $helper->generateForm(array($fields_form)); } private function _postProcess() { if (Tools::isSubmit('submitUpdate')) // handles the basic config update { // Check what's the chosen method if(Tools::getValue('assign_method') == 0) // direct input { // check the input field $ids = Tools::getValue('product_ids'); // regex to check if they are ok if(!preg_match("/^[0-9,]+$/", $ids)) $this->_errors[] = $this->l('Invalid product IDs string'); else { $ids_array = explode(',', $ids); $this->assignCarrier($ids_array); // TODO convert this to a function } } else { // assign by category $id_category = Tools::getValue('assign_categories'); if(!$id_category) $this->_errors[] = $this->l('Error: You must select a category'); else { $category = new Category((int)$id_category); $products = $category->getProductsWs(); if(!$products) $this->_errors[] = Tools::displayError('No product found in the chosen category'); else { foreach ($products as $product => $idpr) $ids_array[] = $idpr['id']; $this->assignCarrier($ids_array); } // TODONEXT pass products to the previous query, convert it to function } } // Error handling if ($this->_errors) { $this->_html .= $this->displayError(implode($this->_errors, '<br />')); } else $this->_html .= $this->displayConfirmation($this->l('Settings Updated!')); } } public function getConfigFull() { // join lang and normal config $config = $this->getConfig(); $config_lang = $this->getConfigLang(); return array_merge($config, $config_lang); } public function getConfig() { $config_keys = array_keys($this->_config); return Configuration::getMultiple($config_keys); } public function getConfigLang($id_lang = false) { if(!$id_lang) { foreach ($this->_config_lang as $key => $value) { $results[$key] = Configuration::getInt($key); } return $results; } else { $config_keys = array_keys($this->_config_lang); return Configuration::getMultiple($config_keys, $id_lang); } } public function assignCarrier($ids_array) { $query_length = 0; Db::getInstance(_PS_USE_SQL_SLAVE_)->query('START TRANSACTION;'); foreach ($ids_array as $id) { // update each product, but do it bulk without autocommit $clause = 'INSERT IGNORE INTO '._DB_PREFIX_.'product_carrier (id_product, id_carrier_reference, id_shop) VALUES ('.$id.','.(int)Tools::getValue('chosen_carrier').','.$this->context->shop->id.');'; $query_length++; $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($clause); // if no rows were affected, we have an error, display it if(!$res) { $this->_errors[] = Tools::displayError('Error on updating the carrier on product #'.$id.': ').mysql_error(); break; } if($query_length == 500) { Db::getInstance()->query('COMMIT'); $query_length = 0; } } // end foreach id if(!Db::getInstance()->query('COMMIT')) $this->_errors[] = Tools::displayError('Error: ').mysql_error(); } public function hookDisplayLeftColumn($params) { $this->context->smarty->assign(array( 'value1' => TRUE, 'value2' => TRUE )); return $this->display(__FILE__, 'carrierassigner.tpl'); } public function hookDisplayRightColumn($params) { return $this->hookLeftColumn($params); } public function hookDisplayHeader($params) { $this->context->controller->addCSS($this->_path.'views/css/carrierassigner.css', 'all'); $this->context->controller->addJS($this->_path.'views/js/carrierassigner.js', 'all'); } }
  5. Io non sono molto bravo di php, credo che basterebbe aggiungere una casella di scelta che mostra i corrieri già configurati nel sito e dare un'istruzione di abbinamento a tutti i prodotti
  6. Ciao, ho un sito con diversi fornitori, i prodotti vengono caricati automaticamente da csv tramite cron, Ogni fornitore ha prezzi di spedizione diverse. Possibile inserire nello script di importazione un codice php che dia la possibilità di scegliere il corriere da associare ai prodotti per quel fornitore?
  7. Ecco i test effettuati, Come sono? sync; dd if=/dev/zero of=tempfile bs=1M count=1024; sync 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 2.54346 s, 422 MB/s dd if=tempfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 0.644408 s, 1.7 GB/s sudo /sbin/sysctl -w vm.drop_caches=3 vm.drop_caches = 3 # dd if=tempfile of=/dev/null bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 1.50129 s, 715 MB/s Timing cached reads: 16460 MB in 1.99 seconds = 8258.12 MB/sec Timing buffered disk reads: 194 MB in 3.00 seconds = 64.59 MB/sec
  8. Ciao, grazie per avermi risposto!!! Ho installato centos 7 Mi spiego meglio Vado su preferenze > cerca e clicco sul link per ricostruire l'indice dei prodotti l'esecuzione dovrebbe partire immediatamente, invece se faccio diversi refresh della pagina per vedere quando inizia ad aggiornare vedo che parte dopo circa un minuto e completa il tutto dopo circa 10 minuti. La stessa cosa mi succede con la generazione della sitemap, dopo 10 ore ancora deve terminare. Dopo tutto questo presumo che sia un problema di configurazione delle variabili in mysql ma non so cosa andare a modificare. Spero di avermi fatto capire
  9. Nella versione prestashop 1.6 attivando la modalità catalogo non mostra più il prezzo e il carrello, nella 1.7 dovrebbe avere la stessa funzione. Altro non so dirti!!!
  10. Salve, Ho bisogno di un vostro consiglio riguardo ad una migliore configurazione di mysql per velocizzare la scrittura e lettura dei dati. Vi posto questo quesito perchè ho notato che l'aggiornamento dell'indice della ricerca e della sitemap ci mettono molto tempo, premetto che ho un catalogo di circa 50000 prodotti. Configurazione VPS: CPU: sei core Processore Intel® Xeon® E5-2620v3, E5-2630v4 or 4114 24 GB RAM (Garantita) SSD 600 GB Porta 100 Mbit/s Informazioni sul server Linux #1 SMP Thu Jan 25 20:13:58 UTC 2018 x86_64 Versione software server Apache Versione di MySQL 10.2.13-MariaDB Versione di PHP 7.1.13 Versione di PrestaShop 1.6.1.18 Motore MySQL InnoDB Driver MySQL DbPDO
  11. Ricevo i seguenti errori in error log: [fcgid:warn] [pid 15146] mod_fcgid: stderr: PHP Notice: Undefined index: reduction in /home/xxxxx/public_html/cache/smarty/compile/21/a1/68/21a16847713e71c0f7805f1a3a88fa120520698a.file.product.tpl.php on line 454 [fcgid:warn] [pid 15146] mod_fcgid: stderr: PHP Notice: Undefined index: reduction in /home/xxxxx/public_html/cache/smarty/compile/21/a1/68/21a16847713e71c0f7805f1a3a88fa120520698a.file.product.tpl.php on line 820 [fcgid:warn] [pid 15146] mod_fcgid: stderr: PHP Notice: Undefined index: reduction in /home/xxxxx/public_html/cache/smarty/compile/21/a1/68/21a16847713e71c0f7805f1a3a88fa120520698a.file.product.tpl.php on line 838 Queste le linee interessate: Linea 454: <div class="reduction_img_container<?php if (!$_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction']) {?> hidden<?php }?>"> Linea 820: <p class="reduction<?php if (!$_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction']) {?> hidden<?php }?>"><?php if ($_smarty_tpl->tpl_vars['product']->value->on_sale) {?><?php echo smartyTranslate(array('s'=>'On sale'),$_smarty_tpl);?> Linea 838: <p class="old_price_display<?php if (!$_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction']) {?> hidden<?php }?>"> Il tema è discountshop version 3.7.6 ho contattato il produttore del tema è mi ha risposto che il supporto è scaduto e il tema non è più supportato. Potreste gentilmente aiutarmi voi a risolvere il problema? Grazie in anticipo!!!
×
×
  • Create New...