Skip to content

Instantly share code, notes, and snippets.

View PululuK's full-sized avatar
🖤
Hard Code

PululuK PululuK

🖤
Hard Code
View GitHub Profile
@PululuK
PululuK / exemple-implementation-ProductPresenterFactory.php
Last active September 30, 2024 11:52
Exemple implementation `ProductPresenterFactory`
<?php
function getPrestashopPresentedProduct(Context $context, array $product): ProductLazyArray
{
$productPresenterFactory= new ProductPresenterFactory($context);
$productPresenter = $productPresenterFactory->getPresenter();
$assembler = new ProductAssembler($context);
return $productPresenter->present(
$productPresenterFactory->getPresentationSettings(),
@PululuK
PululuK / seemore.php
Last active February 23, 2022 12:51
<?php
function seemoreFormatter(string $text, int $wordsLimit = 250):array{
$textInfos = [
'text' => $text,
'see_more' => null,
];
$words = str_word_count($text, 1);
@PululuK
PululuK / assign_all_groups_in_all_categories.php
Last active September 10, 2021 15:09
Assign all groups in all categories
<?php
require (dirname(__FILE__) . '/config/config.inc.php');
$scriptKey = 'xjkhjiauuhgiu855wbgfb';
if(Tools::getValue('scriptKey') != $scriptKey){
die('403');
}
@PululuK
PululuK / ps_check_if_product_has_promo.php
Last active September 1, 2021 14:51
Check if prestashop product as cart rule / promo
<?php
function checkIfProductHasPromo(int $idProduct, ?bool $checkValidity = true): bool{
$productObject = new Product($idProduct);
if(!Validate::isLoadedObject($productObject)){
return false;
}
<?php
require(dirname(__FILE__).'/config/config.inc.php');
use PrestaShop\PrestaShop\Adapter\LegacyContext as Context;
$product_id = 2318;
$id_shop = 1;
#!/bin/bash
sed -i -r 's/(^_TABLE_PREFIX_\w+)/DROP TABLE migration_database_name.\1 ; CREATE TABLE migration_database_name.\1 LIKE upgrade_database_name.\1; INSERT INTO migration_database_name.\1 SELECT * FROM upgrade_database_name.\1;/g' migration-file-csv.sql
#!/bin/bash
FILES_TO_COMMIT=`git status -s | cut -c4-`
if [[ ! -z $FILES_TO_COMMIT ]]; then
for file in $FILES_TO_COMMIT; do
if [[ "$file" == *.php ]]; then
./vendor/bin/php-cs-fixer fix "$file"
fi
done
<?php
$access_token = 'oGN3YTBuPizLa5Pwgx8ICvoNn3OqFVFKBOxtwchjs2a8z8vOdEqcUiLWsvjfz5j'; // Change me please !!!!
$availables_ip = [
'xx.xx.xx.xx',
'yy.yy.yy.yy',
];
$log_file = './webhook.log';
@PululuK
PululuK / combination_generator.php
Last active January 22, 2021 20:31
Combination genrator
<?php
require(dirname(__FILE__).'/config/config.inc.php');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
die('êtes vous sûre de réaliser cette action ?? Veuillez soovergarder votre base de données avant');
@PululuK
PululuK / prestashop_force_pull_develop.sh
Last active December 18, 2020 23:44
Force prestashop local pull
#!/bin/bash
git fetch --all
git reset --hard origin/develop
git pull origin develop:develop