Skip to content

Instantly share code, notes, and snippets.

@ircykk
ircykk / ps17-categories-fix.php
Created October 23, 2021 14:05
Fix product categories tree to display subcategory products in parent category
<?php
// fix product categories tree to display subcategory products in parent category
require dirname(__FILE__).'/config/config.inc.php';
$limit = 100;
$offset = 0;
do {
@ircykk
ircykk / install.sh
Last active November 16, 2019 18:17
Install docker, docker-compose and gitlab-runner for gitlab CI pipeline
#!/bin/sh
# Upgrade
apt-get update
apt-get -y upgrade
# Docker
apt-get remove docker docker-engine docker.io
apt-get --yes --force-yes install \
apt-transport-https \
{if isset($features) && count($features)}
<ul>
{foreach from=$features item=f key=key}
{if $f.name !== 'xxx' && $f.name !== 'zzz'}
<li>{$f.name|escape:'html':'UTF-8'} - <b>{$f.value|escape:'html':'UTF-8'}</b></li>
{/if}
{/foreach}
</ul>
{/if}
@ircykk
ircykk / ps.sql
Created August 20, 2019 09:27
Export PrestaShop products with seo URLs (including category)
# Export PrestaShop products with seo URLs (including category)
# id_lang = xxx, id_shop = yyy (default 1 if not multistore)
SELECT p.id_product, pl.name, CONCAT("https://example.com/", cl.link_rewrite, "/", p.id_product, "-", pl.link_rewrite, ".html") AS url, p.date_add, p.date_upd
FROM ps_product p
INNER JOIN ps_product_lang pl ON (p.id_product = pl.id_product AND pl.id_lang = 1 AND pl.id_shop = 1)
INNER JOIN ps_category_lang cl ON (p.id_category_default = cl.id_category AND cl.id_lang = 1 AND cl.id_shop = 1)
WHERE p.active = 1
ORDER BY `p`.`id_product` DESC
@ircykk
ircykk / OfferStructureBuilder.php
Last active June 26, 2019 18:29
Modyfikacja kolejności zdjęć
public function injectImages($images)
{
foreach ($images as $imagePath => $imageUrl) {
$this->add('images', [['url' => $imageUrl]]);
}
// ten kod dodajemy
if (count($this->structure['images']) > 1) {
$tmp = $this->structure['images'][0];
$this->structure['images'][0] = $this->structure['images'][1];
@ircykk
ircykk / make-override.sh
Created January 23, 2019 14:17
PrestaShop admin controller template override path
mkdir -p override/controllers/admin/templates/products
touch informations.tpl // Product informations tab
@ircykk
ircykk / AdminTranslationsController.php
Created December 30, 2018 13:59
Fix for PrestaShop 1.6 translation bug (save phrase but display old version in editor)
<?php
class AdminTranslationsController extends AdminTranslationsControllerCore
{
public function postProcess()
{
if (function_exists('opcache_reset')) {
opcache_reset();
}
}
}
/**
* Quantity update : skip
*/
$fieldBuilder->removeField(AFField::FID_QTY);
// linia:1354, dodajemy:
$fieldBuilder->removeField(AFField::FID_TITLE);
@ircykk
ircykk / AllegroSyncManager.php
Last active September 7, 2018 09:18
AllegroSyncManager.php
:1687
// Common theme images
if ($allegroProduct->id_allegro_theme >= 0) {
// ...
}
// dodajemy ten kod
foreach (AFField::$FID_IMAGES as $i => $fieldId) {
// jesli slot na zdjecie pusty - dodajemy zdjecie
@ircykk
ircykk / ps_categorytree.php
Last active June 25, 2018 14:00
PrestaShop Ps_CategoryTree Full tree
//...
public function getWidgetVariables($hookName = null, array $configuration = [])
{
$category = new Category((int)Configuration::get('PS_HOME_CATEGORY'), $this->context->language->id);
if (Configuration::get('BLOCK_CATEG_ROOT_CATEGORY') && isset($this->context->cookie->last_visited_category) && $this->context->cookie->last_visited_category) {
$category = new Category($this->context->cookie->last_visited_category, $this->context->language->id);
if (Configuration::get('BLOCK_CATEG_ROOT_CATEGORY') == 2 && !$category->is_root_category && $category->id_parent) {
$category = new Category($category->id_parent, $this->context->language->id);