Skip to content

Instantly share code, notes, and snippets.

View frkosk's full-sized avatar

František Kocúrik frkosk

  • Lighting Beetle
  • Slovak Republic
View GitHub Profile
@frkosk
frkosk / Change categories for products
Last active December 12, 2024 11:49
Prestashop 8 - Manipulating categories in SQL database
-- Definovanie produktov a kategórií ako reťazce
SET @product_ids = '1,2,3';
SET @category_ids = '10,20,30';
-- Definovanie predvolenej kategórie
SET @default_category_id = 10;
-- Vloženie nových kategórií pre produkty
INSERT INTO ps_category_product (id_category, id_product, position)
SELECT
@frkosk
frkosk / gist:936741d31425ea5b2dff5501c5d18cfd
Last active April 23, 2024 17:00
PRESTASHOP 1.6.X ADMIN ERROR 500

PRESTASHOP 1.6.X ADMIN ERROR 500

A common error that could appear after you install prestashop is

Fatal error: Declaration of AdminLoginControllerCore::viewAccess() must be compatible with AdminControllerCore::viewAccess($disable = false) in /var/www/prestashop/controllers/admin/AdminLoginController.php on line 27

or, if you haven’t set prestashop into dev mode, you’ll get a 500 error.

The way to fix this is simple:

@frkosk
frkosk / db_clean.sql
Created October 6, 2023 09:28
Cleaning Prestashop database
/* Delete connections statistics report: Execute SQL Query */
TRUNCATE TABLE ps_connections;
TRUNCATE TABLE ps_connections_source;
TRUNCATE TABLE ps_connections_page;
TRUNCATE TABLE ps_guest;
/* Delete Prestashop Logs: Execute SQL Query */
TRUNCATE TABLE ps_log;
/* Delete Prestashop Referrer statistics report: Execute SQL Query */
@frkosk
frkosk / sample.js
Last active September 7, 2018 11:55
string as an object reference a.k.a Computed property names in react setState
// define setState object based on string reference
const stateNameInString = 'MyState';
const Obj = {};
Obj[stateNameInString] = 'bla bla';
this.setState(Obj);
// OR
@frkosk
frkosk / functions.php
Created June 11, 2018 08:28
Change the language of reCAPTCHA in Contact Form 7 (Wordpress)
<?php
function custom_recaptcha_enqueue_scripts() {
wp_deregister_script( 'google-recaptcha' );
$url = 'https://www.google.com/recaptcha/api.js';
$url = add_query_arg( array(
'onload' => 'recaptchaCallback',
'render' => 'explicit',
'hl' => 'sk-SK' ), $url );
@frkosk
frkosk / gist:f9091b6a044c32e7077a958847079f9e
Last active January 9, 2020 10:21
Prestashop - bulk update product price by reference
UPDATE ps_product_shop SET wholesale_price=0.88, price=0.88 WHERE id_product IN (SELECT id_product FROM ps_product WHERE reference='19-ir8');
UPDATE ps_product SET wholesale_price=0.88, price=0.88 WHERE reference='19-ir8';
@frkosk
frkosk / index.html
Created April 11, 2018 14:56
Canvas Random Circle filled with gradient generator
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Title Page</title>
</head>
<body>
<canvas id="canvas"></canvas>
<input class="switch" type="checkbox">
function getID () {
// Math.random should be unique because of its seeding algorithm.
// Convert it to base 36 (numbers + letters), and grab the first 9 characters
// after the decimal.
return '_' + Math.random().toString(36).substr(2, 9);
};