Skip to content

Instantly share code, notes, and snippets.

View kraken-chris's full-sized avatar

Chris Huffman kraken-chris

  • Kraken Commerce
  • Springfield, MO
View GitHub Profile
@erikhansen
erikhansen / 1_product_queries.sql
Last active July 16, 2025 20:08
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.
*
@chris-huffman
chris-huffman / query_largest_tables.sql
Created January 13, 2021 17:56
Gets the 10 largest tables in a db.
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;
@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": [