Skip to content

Instantly share code, notes, and snippets.

@jonpontet
jonpontet / prestashop_move_overrides.php
Created December 16, 2021 11:57
PrestaShop will only copy automatically to the override folder the PHP file of the same name of the module. Sometimes you need to override other files of a module - with this code you can that in your own custom module.
<?php
// The path to the /override/modules folder in your custom module
$module_path = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->name .
DIRECTORY_SEPARATOR . 'override' . DIRECTORY_SEPARATOR . 'modules';
// The path to the PrestaShop override folder
$override_path = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'override' . DIRECTORY_SEPARATOR . 'modules';
// Add an entry to the array for all of the overrides that you want to be copied to the override folder:
$files = array(
@jonpontet
jonpontet / prestashop_get_module_instance.php
Created December 16, 2021 11:41
How to get a module instance in PrestaShop
<?php
$module = Module::getInstanceByName('module_name');
$module->functionName();
@jonpontet
jonpontet / prestashop_sql_commands.php
Created December 16, 2021 11:41
How to execute SQL statements in PrestaShop
<?php
// SQL SELECT
// Simple SELECT
$sql = 'SELECT `id_authorization_role` FROM `' . _DB_PREFIX_ . 'authorization_role` t WHERE ' . implode(' OR ', $whereClauses);
// Or SELECT with INNER JOIN
$sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'orders o
INNER JOIN ' . _DB_PREFIX_ . 'order_detail od
ON o.id_order = od.id_order
WHERE od.product_id = '. $var
);