Skip to content

Instantly share code, notes, and snippets.

View dfelton's full-sized avatar

Darren Felton dfelton

View GitHub Profile
@dfelton
dfelton / DataPatch.php
Last active September 19, 2024 14:51
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 / 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 / _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 / 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 / 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;
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 / example.php
Created January 14, 2022 19:15
Example of an informative php docblock
<?php
declare(strict_types=1);
namespace Kobens\Gemini\Report\YearToDateVolume;
interface DataProviderInterface
{
/**
* @return \Kobens\Gemini\ApiModels\TradeInterface[]
@dfelton
dfelton / update-ca-certificates.md
Last active January 21, 2022 04:28 — forked from epcim/update-ca-certificates.md
trusted certificates system update-ca-certificates

Adding trusted root certificates to the server

Mac OS X

# Adding Certificate Authority
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ca-filename.crt

# Adding Certificate trusted for SSL
sudo security add-trusted-cert -d -k /Library/Keychains/System.keychain -r trustAsRoot -p ssl filename.crt
@dfelton
dfelton / google-sheets-importrange-generator.php
Created February 18, 2022 22:56
IMPORTRANGE() column generator of months of the years for Google Sheets
<?php
declare(strict_types=1);
$format = '"=IMPORTRANGE(""%s"",""%s!H1"")"';
$months = [
"JAN",
"FEB",
"MAR",
@dfelton
dfelton / nvidia-gpu-brightness.sh
Created March 3, 2022 05:04
NVidia GPU Lights Brightness Adjustment - Linux
nvidia-settings --assign GPULogoBrightness=0