Skip to content

Instantly share code, notes, and snippets.

View groggu's full-sized avatar
🏠
Working from home

Greg Croasdill groggu

🏠
Working from home
View GitHub Profile
@groggu
groggu / getconfigstock.sql
Last active August 29, 2015 14:08
Magento - Get configurable product's total stock qty and is_in_stock status using one child's product ID
SELECT
count(product_id),
sum(cataloginventory_stock_item.qty) as child_qty,
sum(cataloginventory_stock_item.is_in_stock) > 0 as some_child_in_stock
FROM cataloginventory_stock_item
WHERE product_id in (
SELECT
parent.product_id
FROM
catalog_product_super_link as parent
@groggu
groggu / checkinvidx.sql
Created October 24, 2014 14:56
Magento - Validate stock against index values for all simple products
SELECT DISTINCT
catalog_product_entity.entity_id,
catalog_product_entity.sku,
catalog_product_entity.type_id,
cataloginventory_stock_item.qty AS `stock qty`,
cataloginventory_stock_item.is_in_stock,
cataloginventory_stock_status_idx.qty AS `idx qty`,
cataloginventory_stock_status_idx.stock_status
FROM cataloginventory_stock_item INNER JOIN cataloginventory_stock_status_idx ON cataloginventory_stock_item.product_id = cataloginventory_stock_status_idx.product_id
INNER JOIN catalog_product_entity ON catalog_product_entity.entity_id = cataloginventory_stock_item.product_id
@groggu
groggu / .gitignore
Created March 5, 2015 20:06
magento default .gitignore
# General web stuff
/.htaccess
/robots.txt
/sitemap.xml
/google*
# Dynamic Magento data that doesn't need to be in the repo
/var/*
/media/*
@groggu
groggu / foo.sql
Created March 5, 2015 20:09
Get the size of all your mysql databases
SELECT
table_schema as "db name",
SUM( data_length + index_length) / 1024 / 1024 as "Data Base Size in MB"
FROM
information_schema.TABLES
GROUP BY
table_schema;
@groggu
groggu / gist:a384f5a2c3fcfd376edc
Last active August 29, 2015 14:16
htaccess file compression and caching settings for Magento
Update Expires time to increase Browser Caching
At the beginning of the <IfModule mod_expires.c> section replace
<IfModule mod_expires.c>
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
ExpiresDefault "access plus 1 year"
@groggu
groggu / slit_csv.sh
Created August 17, 2015 14:28
Great script to split up large CSV files into parts. Change the term "filename" below to be the csv file name and change the 25000 to be the number of lines in each split file.
tail -n +2 filename.csv | split -l 25000 - filename_
for file in filename_*
do
head -n 1 filename.csv > tmp_file
cat $file >> tmp_file
mv -f tmp_file $file.csv
done
@groggu
groggu / Sony ILCE-6000 (Rokinion 14mm).lcp
Created August 17, 2015 14:31
Adobe Lens description file for Rokinion 14mm Lens
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.4.0-c007 1.126898, 2008/09/29-20:23:32 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
xmlns:stCamera="http://ns.adobe.com/photoshop/1.0/camera-profile">
<photoshop:CameraProfiles>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<stCamera:Author>Thomas Berndt (www.photo-worX.de) - Modified for Sony by Greg Croasdill</stCamera:Author>
@groggu
groggu / db_dump.sh
Created August 17, 2015 14:50
DB Dump script for Magento
#!/bin/bash
IGNORE_TABLES=( dataflow_batch_export dataflow_batch_import log_customer log_quote log_summary log_summary_type log_url log_url_info log_visitor log_visitor_info log_visitor_online report_viewed_product_index report_compared_product_index report_event index_event enterprise_logging_event_changes )
CONFIG_FILE="./app/etc/local.xml"
IGNORE_STRING=""
TMP_FILE="./var/.tmp.local.xml"
if [ ! -f "$CONFIG_FILE" ]; then
echo "$CONFIG_FILE does not exist"
exit
@groggu
groggu / gist:c24ca84d56ee0adfd43e
Last active September 4, 2024 12:44
Here's a bit of SQL code to export all the configurable-simple product relations from a Magento database in a format that MAGMI can import!
SELECT
parent.sku as 'sku',
eav.attribute_code as 'configurable_attribute',
GROUP_CONCAT(child.sku SEPARATOR ',') as 'simples_skus'
FROM catalog_product_super_link
INNER JOIN catalog_product_entity as child ON catalog_product_super_link.product_id = child.entity_id
INNER JOIN catalog_product_entity as parent ON catalog_product_super_link.parent_id = parent.entity_id
INNER JOIN catalog_product_super_attribute as super ON super.product_id = parent.entity_id
INNER JOIN eav_attribute as eav ON eav.attribute_id = super.attribute_id
Group By parent.sku
@groggu
groggu / getNsPromo.php
Last active October 12, 2015 19:54
Lookup NetSuite promotion by coupon code (from custom Magento module)
//assumes you are using the PHPToolKit and have already
// require_once 'lib/NetSuite/NetSuiteService.php';
private function _getNsPromoCode($magePromoCode){
$service = new NetSuiteService();
//get the ID of the coupon by code
$searchData = new SearchStringField();
$searchData->operator = "is";
$searchData->searchValue = $magePromoCode;