Skip to content

Instantly share code, notes, and snippets.

View johnhughes1984's full-sized avatar

John Hughes johnhughes1984

View GitHub Profile
@erikhansen
erikhansen / 1_product_queries.sql
Last active April 2, 2024 01:48
Magento 2 - Remove duplicate store view-specific product and category data
/*
* IMPORTANT: The queries below are written for Magento Enterprise. If you're going to run them on Magento Community, you need
* to replace all instances of ".row_id" with ".entity_id". See this for context: http://magento.stackexchange.com/questions/139740/magento-2-schema-changes-for-ee-catalog-staging
*
* When importing products in Magento 2, if you specify store view codes in the store_view_code column, product data will be set at
* both the global scope as well as the specific store view scope. This is not ideal because now you have duplicate
* data at two different scopes that shouldn't actually be duplicated. The scripts below clean up this data by finding
* data set at specific store view scopes and if it's an exact match to the data set at the global store view, then it
* deletes the data set at the specific store view scope.
*
@IvanChepurnyi
IvanChepurnyi / optimize-composer.sh
Created September 30, 2016 16:00
Optimizes autoloader for the best performance on production system
#!/bin/bash
magentodir=$1
cd $magentodir
read -d '' script << PHP
<?php
\$composer = json_decode(file_get_contents('composer.json'), true);
if (!is_array(\$composer['autoload']['psr-0'][''])) {
@pronto2000
pronto2000 / products.php
Last active June 12, 2016 14:02
Magento: Snippet to update all products (put it into the shell folder)
<?php
require_once 'abstract.php';
class Mage_Shell_Products extends Mage_Shell_Abstract
{
private function execution_time($start, $current)
{
return date("H:i:s", $current - $start);
}
@bh-ref
bh-ref / RemoveOptions.php
Last active December 28, 2021 21:06
Remove/Delete Product Attribute Options in Magento 2
<?php
namespace Vendor\ModuleName\Options;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory;
class RemoveOptions
{
@piotrekkaminski
piotrekkaminski / gist:9bc45ec84028611d621e
Last active August 8, 2023 08:38
How to automatically download patches and release of Magento
1) First you need to generate download token. Login to your account on magento.com and generate it in Account Settings->Downloads Access Token
2) You will need your MAGEID as well. It is shown at the top-left in your account page.
3) curl -k https://MAGEID:TOKEN@www.magentocommerce.com/products/downloads/info/help
4) Profit!
@adilbaig
adilbaig / git-updater
Last active November 30, 2023 12:49
A bash script to update your git repos in the background. It also pops up a user notification when a repo is synced
#!/bin/bash
# This is required for `notify-send` to work from within a cron.
# http://askubuntu.com/questions/298608/notify-send-doesnt-work-from-crontab/346580#346580
eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)";
# syncAndWink
#
# Syncs all remotely-tracked branches on a git repo passed as first argument ($1). It also pulls any new branches
# and tags attached to the repo.
@avoelkl
avoelkl / magestackday.md
Last active June 18, 2016 15:54
MageStackDay little helpers

MageStackDay notes & queries

Some notes from the MageStackDay chat:

  • save your votes. Marius can close unlimited nrs of questions so he'll do that, just vote / flag once is enough!
  • If you can clean up the spelling and grammar on the question, feel free to do so, as it would be easier for non-english speakers
  • use your votes

Queries

Questions to work on

@jonathansayag
jonathansayag / magento-delete-attribute-options.php
Last active March 28, 2019 17:48
Magento PHP script to delete all values of an attribute
<?php
$attribute_code = 'ATTRIBUTE_NAME';
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribute_code);
$options = $attribute->getSource()->getAllOptions();
$optionsDelete = array();
foreach($options as $option) {
if ($option['value'] != "") {
$optionsDelete['delete'][$option['value']] = true;
@GianlucaGuarini
GianlucaGuarini / post-merge
Last active August 22, 2023 20:54 — forked from sindresorhus/post-merge
Git hook that gets triggered after any 'git pull' whenever one of the files specified has changed. Useful to update any web application dependency using bower npm or composer
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# forked by Gianluca Guarini
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
}
<?php
/**
* Generates data with ready-to-edit CSV for magento translation
*
* A handy tool that generates CSV data for magento theme translation
* You can set the $mode to:
* a) either write that data to translate.csv at path you specify,
* b) or just to dump that data in browser for you to copy and use (default).
* In the write mode it appends new data to translate.csv thus you dont