Skip to content

Instantly share code, notes, and snippets.

View PrestaEdit's full-sized avatar
:octocat:

Jonathan Danse PrestaEdit

:octocat:
View GitHub Profile
@PrestaEdit
PrestaEdit / gist:10270131
Created April 9, 2014 13:25
PrestaShop | Image upload
$field_name = 'block_img';
$temp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS');
$salt = sha1(microtime());
$type = strtolower(substr(strrchr($_FILES[$field_name]['name'], '.'), 1));
if ($error = ImageManager::validateUpload($_FILES[$field_name]))
$this->_html .= $this->displayError($error);
elseif (!$temp_name || !move_uploaded_file($_FILES[$field_name]['tmp_name'], $temp_name))
$this->_html .= $this->displayError($this->l('An error occurred during the image upload'));
elseif (!ImageManager::resize($temp_name, dirname(__FILE__).'/img/'.$salt.'.'.$type))
$this->_html .= $this->displayError($this->l('An error occurred during the image upload.'));
@PrestaEdit
PrestaEdit / AdminXXXController.php
Created September 16, 2014 22:14
AdminXXXController extends ModuleAdminController
public function renderForm()
{
// ...
$this->fields_form[0]['form'] = array(
array(
'label' => $this->l('Manufacturers:'),
'name' => 'manufacturers',
'type' => 'checkbox_manufacturers',
'values' => array(
@PrestaEdit
PrestaEdit / gist:27ed4cdd770ee050c398
Last active February 21, 2018 15:38
Install PrestaShop with CLI
$ php index_cli.php --domain=example.com --db_server=sql.example.com --db_name=prestashop --db_user=root --db_password=123456789
@PrestaEdit
PrestaEdit / gist:fd0d4188eaab1aa26172
Created December 23, 2014 09:32
Supprimer le dernier caractere d'une chaine
substr($string,0,-1);
@PrestaEdit
PrestaEdit / PrestaShop - Module dashboard
Last active August 29, 2015 14:12
PrestaShop - Module dashboard
A few new variables are necessary for a proper dashboard module:
$this->push_filename: the directory where your push data should be stored.
$this->allow_push: a boolean indicating whether your module should have data be pushed to it. or not.
$this->push_time_limit: the numbers of seconds between two data pushes.
PrestaShop 1.6 implements several new hooks dedicated to dashboard modules:
dashboardData: how you want your data to be handled.
dashboardZoneOne: enables you to display your content in the left column of the dashboard zone.
dashboardZoneTwo: enables you to display your content in the central column of the dashboard zone.
On obtient les données contenues dans le fichier "01. Datas".
On ne sait pas si les 4 tableaux (object_type_1, object_type_2, ...) seront ou non remplis.
On ne sait pas le nombre de données contenues par tableau.
On souhaite combiner les données (critères) pour obtenir l'ensemble des combinaisons possibles en les associant.
Exemple illustré de résultat: 03. Combinations
@PrestaEdit
PrestaEdit / gist:5b896381c9de168c7f30
Created January 21, 2015 09:28
Datepicket: z-index
$(".datepicker").datepicker({
prevText: '',
nextText: '',
dateFormat: 'yy-mm-dd',
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 99999999999999);
}, 0);
}
});
@PrestaEdit
PrestaEdit / gist:272cc6af0fcc75444f80
Last active October 26, 2016 13:17
getCmpResults
/******* BEGIN: getCmpResults() *******/
public function getCmpResults()
{
$sql = 'SELECT *, "category" as type
FROM (
SELECT
queryCmp.sFilename as new_name, queryCmp.sFilePath as path, queryCmpFinal.id_category, "" as id_product, "" as id_feature_value, queryCmpFinal.id_lang, queryCmpFinal.category_name as old_name, "" as field, "" as value,
CASE WHEN queryCmp.sFilename is null THEN "delete"
WHEN queryCmpFinal.category_name is null THEN "create"
WHEN queryCmp.sFilename <> queryCmpFinal.category_name THEN "update"
1. Folder like that:
-- Folder
--- Classes
--- FirstClass.php
--- SecondClass.php
2. A PHP file for do that:
-- Check folder Classes
--- See two .php file
---- "preg_match" all string related to a regexp (Like "doIt('[A-Z]')" for doIt('aString') or doIt('anotherString'))
@PrestaEdit
PrestaEdit / PrestaShop_1.5.2.0.lib
Created August 16, 2015 21:28
PrestaShop_1.5.2.0.lib
<?xml version="1.0"?>
<lib>
<name>PrestaShop 1.5.2.0</name>
<type>PrestaShop</type>
<classes>
<class name="Address">
<methods>
<method type="public">__construct($id_address = null, $id_lang = null)</method>
<method type="public">add($autodate = true, $null_values = false)</method>
<method type="public">update($null_values = false)</method>