Skip to content

Instantly share code, notes, and snippets.

@trabulium
trabulium / is_anchor.sql
Created May 18, 2018 00:04
Bulk Update "Is Anchor" based on parent id
#select * from catalog_category_entity_int
UPDATE catalog_category_entity_int
SET value = 1
WHERE attribute_id = (SELECT attribute_id
FROM eav_attribute
WHERE attribute_code = 'is_anchor'
LIMIT 1)
AND entity_id in (select entity_id from catalog_category_entity where path like ('2297%')) and value = 0;
select email, customer_id, product_id, sku, cpev.value, add_date from product_alert_stock as pas
left join catalog_product_entity as cpe on pas.product_id = cpe.entity_id
left join catalog_product_entity_varchar as cpev on cpev.`entity_id` = cpe.entity_id
where add_date > '2017-03-16 00:00:00'
and send_date is NULL
and cpev.attribute_id = 71
order by cpev.value;
update
sales_flat_order_grid as sfog
inner join (
select entity_id, status
from sales_flat_order as sfotmp
) as sfo on sfo.entity_id = sfog.entity_id
set sfog.status = sfo.status
#where sfog.entity_id in (111194)
<?php
define('MAGENTO_ROOT', "/var/www/hatsbythe100.com.au/web");
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
umask(0);
Mage::app();
Mage::app()->getStore()->setId(0);
@trabulium
trabulium / change-dropdown-attribute-to-multiselect.sql
Last active August 15, 2017 00:14 — forked from dinhkhanh/change-dropdown-attribute-to-multiselect.sql
Magento change dropdown attribute to multiselect
-- First, update the attribute input type to multiselect
UPDATE eav_attribute SET
entity_type_id = 4,
attribute_model = NULL,
backend_model = 'eav/entity_attribute_backend_array',
source_model = NULL,
backend_type = 'varchar',
backend_table = NULL,
frontend_model = NULL,
frontend_input = 'multiselect',
SELECT * FROM `catalog_product_entity` where entity_id
not in (SELECT product_id FROM `catalog_product_super_link`) and type_id='simple'
#!/bin/bash
CHECKOUTS_IP=`/bin/grep saveOrder /var/log/httpd/access.log | grep -v "js\|media\|css\|skin" | awk {'print $1'} | sort | uniq -c | sort -rn | head -1 | awk {'print $2'}`
CHECKOUTS_QTY=`/bin/grep saveOrder /var/log/httpd/access.log | grep -v "js\|media\|css\|skin" | awk {'print $1'} | sort | uniq -c | sort -rn | head -1 | awk {'print $1'}`
CHECKOUTS_COUNTRY=`/usr/bin/geoiplookup $CHECKOUTS_IP | grep Country | awk {'print $5'}`
if [[ $CHECKOUTS_QTY -gt 4 && $CHECKOUTS_COUNTRY != "Australia" ]]
then
#echo $IPADDRESS
/usr/sbin/csf -d $CHECKOUTS_IP
@trabulium
trabulium / mage2yotpo.sql
Last active July 14, 2017 05:47
Export Reviews from Magento to Yotpo format
select DISTINCT cpe.entity_id product_id, cpev3.value product_title, CONCAT('http://www.domain.com.au/', cur.request_path) product_url, rd.detail review_content, rov.value review_score, rd.title review_title, rd.nickname display_name, ce.email email, CONCAT('http://www.domain.com.au/media/catalog/product', cpev2.value) product_image_url, DATE_FORMAT(r.created_at,'%Y-%m-%d') date, '' product_description, '' cf_title_X, '' review_image_urls, '' comment_content, '' comment_public, '' comment_created_at
from review as r
LEFT JOIN review_detail rd on r.review_id = rd.review_id
LEFT JOIN catalog_product_entity cpe on r.entity_pk_value = cpe.entity_id
LEFT JOIN catalog_product_entity_int cpei on cpei.`entity_id` = cpe.entity_id
LEFT JOIN catalog_product_entity_varchar cpev on cpev.entity_id = cpe.entity_id
LEFT JOIN catalog_product_entity_varchar cpev2 on cpev2.entity_id = cpe.entity_id
LEFT JOIN catalog_product_entity_varchar cpev3 on cpev3.entity_id = cpe.entity_id
LEFT JOIN rating_option_vote rov on rov.review_
@trabulium
trabulium / stamped_reviews_export.sql
Last active May 11, 2017 03:56
Export Magento Reviews in Stamped.io format
select distinct cpe.entity_id product_id_maybe, cpe.sku product_id, CONCAT('http://www.domain.com/', cur.request_path) productUrl, cpev.value productUrl, null reviewphotosUrl, rov.percent rating_percent, rov.value rating_of_5, rd.title title, rd.nickname author, ce.email, rd.detail body, r.created_at, CONCAT('http://www.domain.com', cpev2.value) productImageUrl
from review as r
LEFT JOIN review_detail rd on r.review_id = rd.review_id
LEFT JOIN catalog_product_entity cpe on r.entity_pk_value = cpe.entity_id
LEFT JOIN catalog_product_entity_int cpei on cpei.`entity_id` = cpe.entity_id
LEFT JOIN catalog_product_entity_varchar cpev on cpev.entity_id = cpe.entity_id
LEFT JOIN catalog_product_entity_varchar cpev2 on cpev2.entity_id = cpe.entity_id
LEFT JOIN rating_option_vote rov on rov.review_id = r.review_id
LEFT JOIN customer_entity ce on ce.entity_id = rd.customer_id
LEFT JOIN core_url_rewrite cur on cur.product_id = cpe.entity_id
@trabulium
trabulium / find_simple_orphans.sql
Created May 3, 2017 23:31
Find Orphan Simple Products without Parent Configurable
select
type_id,sku, cpev.value
from catalog_product_entity a
left join catalog_category_product cp on cp.`product_id` = a.entity_id
left join catalog_product_relation cpr on cpr.child_id = a.entity_id
left join catalog_product_entity_varchar cpev on cpev.entity_id = a.entity_id
left join catalog_product_entity_int cpei on cpei.entity_id = a.entity_id
where
# add this if you want to filter by no category
# cp.product_id is null