Tag: prestashop

Fixing the Extreme Load Time When Creating a New Product in PrestaShop 1.7.8.10: A Simple Code Replacement to Avoid a Heavy SQL Query That Slows Down Everything

Fixing the Extreme Load Time When Creating a New Product in PrestaShop 1.7.8.10: A Simple Code Replacement to Avoid a Heavy SQL Query That Slows Down Everything If you are running PrestaShop 1.7.8.10 and you have a database with a huge number of products, let’s say 600,000 products or more, and you try to add a new product in the Back Office, but suddenly you notice that your SQL server is under extreme load and everything slows down to the point that the new product page takes forever to open, then you might be facing a serious issue caused by a badly written SQL query, a query that someone thought was a great idea but in reality, it is causing massive performance problems by trying to determine the most used tax rule group by scanning the entire database in an extremely inefficient way, a method that simply does not scale when dealing with large product databases, and the worst part is that this query is executed every single time you try to open the product creation page, making the experience painfully slow and completely unacceptable for any serious e-commerce store running a large catalog. 🔎 Understanding the Problem: The Query

Leggi Tutto »

Prestashop > 1.7.8 change UPC , name, meta and seo max lenght

With prestashop 1.7.8 update lot of thing change regarding field validation, so previous modification that work on prestashop version does not work. This guide can help you to change lenght but also field content validation, this usually is used for change UPC lenght, name lenght, meta title , description lenght ecc. 1) Change every field lenght value in database, for example ps_product.upc and ps_product_lang.name and ps_product_attribute.upc according to the new value you need. 2) Change in Classes\Validate.php Classes\Validate.php change isUpc validation to something like this: return !$upc || preg_match(‘/^[^<>={}]*$/’, $upc); or #return !$upc || preg_match(‘/^[0-9]{0,255}$/’, $upc); 3) In src\PrestaShopBundle\Form\Admin\Product\ProductCombination.php change ‘attrivute_upc’ regex 0,12 to 0,255 new Assert\Regex(‘/^[0-9]{0,255}$/’), or to allow extra character: new Assert\Regex([ ‘pattern’ => ‘/^[^<>={}]*$/’ ]), 4) Same in ProductOptions.php 5) in ProductSeo.php change meta_description and meta_title ‘counter’ => 128, to what do you have se in point 1. 6) in src\Core\Domain\Product\ProductSettings.php change constant value: public const MAX_NAME_LENGTH = 192; 7) in \src\PrestaShopBundle\Form\Admin\Product\ProductInformation.php chang new Assert\Length([‘min’ => 3, ‘max’ => 128]), 8) in src/Core/Domain/Product/ValueObject/Upc.php: public const VALID_PATTERN = ‘/^[0-9]{0,12}$/’; and public const MAX_LENGTH = 255;

Leggi Tutto »
IT
Matteo Lavaggi

Prestashop 1.7.x e il problema delle Slow Queries: come ottimizzare la tua piattaforma e-commerce

Prestashop 1.7.x e il problema delle Slow Queries: come ottimizzare la tua piattaforma e-commerce Introduzione Prestashop è uno dei più popolari sistemi di gestione e-commerce disponibili oggi. Ma come con ogni software, ci sono sempre delle sfide e delle questioni che emergono, specialmente quando il software inizia ad adattarsi alle esigenze crescenti dei suoi utenti. La Sfida delle Slow Queries Una delle principali criticità che molti utenti di Prestashop 1.7.x stanno riscontrando, specialmente quelli con grandi database di prodotti, è il problema delle slow queries. Queste sono le query al database che richiedono molto tempo per essere eseguite e possono influenzare significativamente le prestazioni del tuo sito web. Il problema diventa particolarmente evidente quando si ha un database che contiene centinaia di migliaia di prodotti e di prezzi specifici. Un esempio di una delle query più frequentemente lente può essere visto nel log del database: SELECT COUNT(DISTINCT `id_product`) FROM `ps_specific_price` WHERE `id_product` != 0 LIMIT 1; Questa query viene eseguita ogni volta che un utente visita una pagina prodotto. Il suo scopo principale è di “ottimizzare” la cache della risposta fornita dal motore del database. Ma, come si può facilmente intuire, c’è un grosso problema con questa query. L’Origine del

Leggi Tutto »
IT
Matteo Lavaggi

Prestashop Slow Query Cloud SQL CPU Performance Benchmark

Prestashop è una piattaforma ecommerce opensource relativemente versatile, che sicuramente non brilla per prestazioni, performance e team di sviluppo. Nonostante questo è una scelta ottima per gli ecommerce di piccole e medie dimensioni in quanto semplice da mantenere e relativamente poco assetata di risorse. Tuttavia un design del codice non splendido può portare rapidamente alla formazione di colli di bottiglia nelle performance del sito, e dove non si può intervenire sistemando il codice (che è sempre la soluzione consigliata), quello che rimane da fare è scalare verticalmente la potenza dei server (prestashop non è una piattaforma ecommerce che può scalare nativamente in orizzontale). Questo è il risultato che si può avere pasando da un SQL server cloud HA (Google Cloud SQL) 2 CPU e 7GB di ram a 4CPU e 10 GB di RAM. Come potete vedere le query più “pasticciate” hanno tempi di esecuzione ridotti del 70%, a discapito di un costo raddoppiato (che in configurazione HA è di fatto quadruplicato per la copia di replica del database). Non serve ovviamente citare l’estrema semplicità della gestione di un database Cloud SQL raffrontata alla necessità di gestire un cluster autonomo, ovviamente con qualche downside riugardo al rapporto costo/prestazioni che è

Leggi Tutto »
IT
Matteo Lavaggi

Risparmiare spazio nella cartella immagini di Prestashop per cataloghi con molte foto uguali

Il problema delle dimensioni della cartella img Se avete mai gestito un ecommerce dotato di un grande catalogo prodotti, dove numerosi prodotti hanno la stessa foto (immaginate ad esempio un catalogo di prodotti generici, oppure un catalogo dove lo stesso prodotto viene caricato più volte per avere la compatibilità con differenti applicazioni), sicuramente vi sarà capitato di fare i conti con le dimensioni estremamente elevate della cartella immagini! Facciamo un esempio: Un esempio di uno dei nostri clienti (www.sixrace.it) può descrivere ancora meglio il problema: Sixrace vende ricambi e accessori per moto delle migliori marche, il loro catalogo conta centinaia di migliaia di articoli, molti dei quali presentano numerose foto ciascuno (anche 20). I prodotti caricati sul sito prestashop sixrace.it vengono caraicati numerose volte in quanto lo stesso prodotto può essere compatibile con moto differenti, per favorire l’indicizzazione google e la vendita tramite marketplace e comparatori, sixrace, ha scelto di caricare un singolo prodotto per ogni compatibilità , così da ottimizzare il seo e la ricerca da parte dei clienti. Se prendiamo ad esempio un prodotto quasi universale come una batteria, lo stesso codice viene caricato come centinaia di prodotti differenti, ciascuno con titolo differente (comprendente l’indicazione del modello di

Leggi Tutto »

Prestashop LiteSpeed + LiteCache vs Apache2 + FullPageCache – Speed TEST

Configurazione Server: apws (server Apache2) Apache2 4 core 4GB RAM PHP7.2-FPM Pretashop 1.7.6.9 + Full Page Cache Plugin 1.4 lsws (Server LiteSpeed) Litespeed Enterprise 1 core 2Gb RAM LSPHP72 Prestashop 1.7.6.9 + LiteCache Plugin 8.1.2 Apache Benck Test ab -k -n 1000 -c 20 https://lsws Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests Server Software: nginx/1.18.0 Server Hostname: lsws Server Port: 443 SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256 Server Temp Key: X25519 253 bits TLS Server Name: lsws Document Path: /it/ Document Length: 457133 bytes Concurrency Level: 20 Time taken for tests: 3.953 seconds Complete requests: 1000 Failed requests: 0 Keep-Alive requests: 0 Total transferred: 457467000 bytes HTML transferred: 457133000 bytes Requests per second: 252.96 [#/sec] (mean) Time per request: 79.064 [ms] (mean) Time per request: 3.953 [ms] (mean, across all concurrent requests) Transfer rate: 113009.16 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 2 5 4.9 4 43 Processing: 4 73 38.9 69 368 Waiting: 2 36 20.6 33 129 Total: 7 78 39.0 74 370 Percentage of the requests served within a certain time

Leggi Tutto »

LiteSpeed – Prestashop Login Error 500 [STDERR] PHP Fatal error: Uncaught Error: Call to undefined function Httpful\curl_init()

Errore: Error 500 quando si prova a fare il login dal frontend (redirect login=back=my-account) CMS: Prestashop 1.7.6.9 Server: Ubuntu 20.04+Litespeed Enterprise Cache: LiteSpeed Cache Log: /usr/local/lsws/logs/error.log [STDERR] PHP Fatal error: Uncaught Error: Call to undefined function Httpful\curl_init() Soluzione: sudo apt-get install lsphpXX-curl

Leggi Tutto »