Skip to content

Instantly share code, notes, and snippets.

View perryholden's full-sized avatar

Perry D. Holden perryholden

  • Ozark, MO
View GitHub Profile
@perryholden
perryholden / find_orphaned_files.php
Last active October 11, 2023 15:10
Finds orphaned files from deleted products in Magento 2 (partially generated with ChatGPT v4)
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
/*
* There are a few instances where a file exists in the EAV tables, yet not in the media table, therefore, we should just keep these.
* These were generated by the following SQL (please update attribute IDs, if needed):
SELECT `value` AS 'image'
FROM catalog_product_entity_varchar
@perryholden
perryholden / debug_elasticsearch.txt
Last active October 11, 2023 15:09
Debug Elasticsearch Results
\Magento\Elasticsearch7\SearchAdapter\Adapter::query (This kicks off the entire request)
\Elasticsearch\Connections\Connection::performRequest line 210 (This is the formatted $body variable)
Take the serialized $body varable, then replace the -d argument with the contents:
curl -H 'Content-Type: application/json' -XPOST "http://elasticsearch:9200/magento2_product_1/_search?pretty" -d'{
"from": 0,
"size": 48,
"stored_fields": "_none_",
"docvalue_fields": [
@perryholden
perryholden / dangerous_functions.php
Last active March 8, 2023 16:50
Test File or Folder for Dangerous PHP Functions
<?php
/**
* dangerous_functions.php
* Perry Holden <perry.holden@gmail.com>
*
* Usage: php dangerous_functions.php [type: folder|file] [folder_or_filename]
* Example: php dangerous_functions.php folder vendor/businessname/module-name
*/
if (!isset($argv[1])) {