Skip to content

Instantly share code, notes, and snippets.

View dfelton's full-sized avatar

Darren Felton dfelton

View GitHub Profile
coffee() {
ps aux | grep -v grep | grep caffeinate > /dev/null
if [ $? -eq 1 ]; then
caffeinate -dimsu &
fi
}
killCoffee() {
ps aux | grep -v grep | grep caffeinate > /dev/null
if [ $? -eq 0 ]; then
kill $(pgrep -f caffeinate)
@dfelton
dfelton / DeleteAllProducts.php
Last active December 7, 2020 17:20
Magento Delete All Products
<?php
declare(strict_types=1);
namespace VendorName\ModuleName\Console\Command;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ProductFactory;
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
use Magento\Framework\App\State;
@dfelton
dfelton / Select Option Labels and Swatches.md
Last active November 6, 2020 13:54
Magento 2 Queries

Add in conditions at the bottom for filtering.

SELECT
   `entity`.`entity_type_code`,
   `attr`.`attribute_code`,
   `store`.`code` AS `store_code`,
   `store`.`store_id`,
   `option`.`option_id`,
 `option`.`sort_order`,
@dfelton
dfelton / _Find or Remove Trailing Spaces.md
Last active November 2, 2020 01:09
Find / remove trailing spaces in file(s) in a directory

Linux compatible instructions for finding and/or removing trailing spaces from non-binary files.

@dfelton
dfelton / commands.md
Created September 16, 2020 15:28
Magento 2 - Enable and show all products
./bin/magento config:set cataloginventory/options/show_out_of_stock 1
./bin/magento config:set cataloginventory/options/can_subtract 0
./bin/magento config:set cataloginventory/item_options/manage_stock 0
update catalog_product_entity_decimal
set value = '9999.99'
@dfelton
dfelton / DataPatch.php
Last active September 28, 2022 15:30
Magento 2 EAV properties defaults and mappings
<?php
declare(strict_types=1);
namespace VendorName\ModuleName\Setup\Patch\Data;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UninstallInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
@dfelton
dfelton / createSampleData.php
Created June 25, 2020 22:00
Generates sample data in Magento by via cURL requests to the Magento admin. Useful if CLI access and access to System -> Import/Export is restricted.
<?php
class Config
{
public static $adminUsername = '';
public static $adminPassword = '';
public static $expectedLoginLandingRoute = '/index/index/';
public static $authCookieName = 'adminhtml';
@dfelton
dfelton / pushToDev.sh
Last active July 10, 2020 18:42
Bash function that pushes current branch to upstream development branch
pushToDev() {
php -nr '
function getCurrentBranchName(): ?string {
$branches = shell_exec("git branch 2>/dev/null");
$branchName = null;
if (is_string($branches)) {
$branches = explode(PHP_EOL, trim($branches));
foreach ($branches as $branch) {
if (strpos($branch, "*") === 0) {
$branchName = trim(substr($branch, 1));
@dfelton
dfelton / .zshrc
Last active March 30, 2023 15:58
Z Shell profile for maxOS
# Terminal Styling
setopt prompt_subst
autoload -Uz vcs_info
zstyle ':vcs_info:*' stagedstr 'M'
zstyle ':vcs_info:*' unstagedstr 'M'
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' actionformats '%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:*' formats \
@dfelton
dfelton / 000 - Magento 2 Cheat Sheet.md
Last active January 10, 2020 01:59
Magento 2 Cheat Sheet

Just a cheat Sheet