Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block mokanfar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Useful javascript snippets.js
//find sku in json object list return arg[1] of that object
const filterIt = (sku, attr) => {
let arr = list.filter(function(asdf) {
return asdf.SKU == sku;
return arr[0][attr];
//ramda find without for each
R.find(R.propEq('a', 2))(xs)
View CSS Responsive Skeleton Template
Small Screen - Tablet
@media screen and (min-width: 768px) and (max-width: 991px) {
View Magmi Customer Price Groups Spreadsheet Attributes
group_price:5_percent_off_regular group_price:arizona group_price:chicago group_price:flooring group_price:regular

Magento Code Snippets

##DB Dump n98 magerun command no hangup

nohup ./n98-magerun.phar db:dump --compression="gzip" labdz &
#dev dump without useless info:
nohup ./n98-magerun.phar db:dump --compression="gzip" --strip="@development" labdz &

Image Bash Script Downloader Generator Folder Gallery and Main

mokanfar /
Last active Oct 23, 2018
Matched Rows, Unique Rows Merge Filter Bash Scripts for CSV files
#!/usr/bin/env bash
echo "filename 1 (file that has more rows):"
read file1
echo "filename 2:"
read file2
echo "common field name:"
read fieldname
#echo "file1: ${file1}.csv file2: ${file2}.csv common field name: ${fieldname}"
if [ -f $PWD/temp.db ]; then
View get_final_price_of_skus_for_certain_customer_group.php
require_once 'app/Mage.php';
//to overwrite limit but you need first to increase your memory limit
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*') // select all attributes
->setPageSize(5000) // limit number of results returned
->setCurPage(1); // set the offset (useful for pagination)
// we iterate through the list of products to get attribute values
mokanfar / list_all_gallery_images_magento_product_by_sku.php
Last active Aug 24, 2018
get all images associated with an array of product sku's programatically in Magento [first one is base/main image]
View list_all_gallery_images_magento_product_by_sku.php
mokanfar / bulk_set_array_of_skus_attribute_programatically_in_magento.php
Last active Jul 18, 2018
Magento update from list of skus an attribute programatically
View bulk_set_array_of_skus_attribute_programatically_in_magento.php
require_once 'app/Mage.php';
$skus = array("ARRAY OF SKUS HERE");
foreach ($skus as $item) {
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $item)->getId();
array_push($n, $product);
View gist:c13a524c2b900da80143d81a52ee945f
git clone
cd public_html/shop
curl > .gitignore
git init
git add --all
git commit -m 'backup'
git status
cd ..
#read xlsx
in2csv a.xlsx
#convert xlsx to csv (also works for xls)
in2csv a.xlsx > data.csv
#pretty print stdout spreadsheet
csvlook data.csv | less -S
#display column names
You can’t perform that action at this time.