Skip to content

Instantly share code, notes, and snippets.

View denchev's full-sized avatar

Marush Denchev denchev

View GitHub Profile
@denchev
denchev / sfcc-properties-to-csv.php
Last active May 13, 2022 14:48
Scan a folder of a Salesforce Commerce Cloud project for .properties files and then moves each line to a CSV by preserving the path. Used for translations if you have to give it to an agency.
<?php
$root = realpath('./');
$cartridges = [];
$countries = ['bg', 'sl', 'et', 'hu', 'nl', 'sv', 'da', 'de', 'pt', 'fi', 'it', 'ja', 'ro', 'ko', 'lt', 'pl', 'lv', 'lb', 'ca', 'es', 'fr', 'hr', 'ro', 'ru', 'sk', 'el', 'cs', 'zh', 'no', 'tr'];
$locales = ['nl_BE', 'de_DE', 'ja_JP', 'en_JP', 'en_DE', 'en_PH', 'en_US', 'en_HU', 'fr_FR', 'fr_IT', 'it_IT', 'zh_CN', 'en_GB'];
function findLanguageProperties($start, $cartridges) {
global $countries, $locales;
@denchev
denchev / gist:3bdfd7bf1ed45d8f1d44387c4211d84b
Last active February 2, 2021 12:27
Export all tables but only essential data from Magento 2
#!/bin/sh
###
### Modify this variable only. It should point to your app/etc/evn.php file.
ENV_FILE="/app/p2f3xbqpgpxow/app/etc/env.php"
###
###
extract_from_env () {
dirty=$(grep -m 1 $1 $ENV_FILE)
@denchev
denchev / AddImageToCompareProductsPlugin.php
Created January 27, 2018 15:33
Magento 2 show image in sidebar compare list
<?php
namespace Vendor\Namespace\Plugin;
use Magento\Catalog\Helper\ImageFactory;
use Magento\Catalog\Helper\Product\Compare;
use Magento\Catalog\Model\ProductRepository;
class AddImageToCompareProductsPlugin
{
@denchev
denchev / fee-orders.php
Created June 16, 2016 05:53
Get a list of all WooCommerce orders that have fees negative applied.
<?php
/**
* Get a list of all WooCommerce orders that have negative fees applied.
* Installation: Just put it in your root folder (where wp-config.php is). Execute the file /fee-orders.php.
*
*/
require_once "wp-load.php";
@denchev
denchev / helpers.less
Last active August 29, 2015 14:10
Useful LESS helpers.
@margin: 10px;
@margin-thin : @margin/2;
@margin-thiner : @margin/3;
@margin-thinest : @margin/4;
@margin-thick : @margin*2;
@margin-thicker : @margin*3;
@margin-thickest : @margin*4;
.helper(@value:@margin);
.helper(@name:-thin,@value:@margin-thin);
@denchev
denchev / request.php
Last active August 29, 2015 14:07
Get remote URL content
<?php
function request($url, $cache = false) {
$prefix = 'cache_response_';
if($cache === true) {
$folder = dirname(__FILE__ ) . DIRECTORY_SEPARATOR . 'cache';
$folder = file_exists($folder) && is_writable($folder) ? $folder : '/tmp';
$file = $folder . '/' . $prefix . md5($url);
<?php
/*
Increase or decrease value in CakePHP with little footprint.
Add this to your AppModel.
Usage:
(in Controller)
$this->Model->increase('field_name', 1);