Skip to content

Instantly share code, notes, and snippets.

<?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);
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)
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;
@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;
@trabulium
trabulium / am_shopby_value
Created May 28, 2018 07:05
Bulk add am_shop_by images based on the brand name / meta title
UPDATE am_shopby_value
SET img_medium = Concat(Lower(REPLACE (meta_title, ' ', '-')), '.jpg')
WHERE img_medium = ''
AND filter_id = 1
AND meta_title NOT LIKE ( "a:%" );
@trabulium
trabulium / magento1_clone_gallery_position_label_new_store
Last active July 6, 2018 00:08
Copy Image position and label from Store Id 6 to Store ID 5 where position is '2'
@trabulium
trabulium / mage1_remove_fax_bad_phone
Created July 6, 2018 00:10
Magento 1 - Remove Fax #'s and remove email address and Alphanumeric from Phone Field on customer accounts
Attribute IDs 32, 178 for Fax
Attribute IDs 31, 175 for Phone
update customer_address_entity_varchar set value = '' where attribute_id in (32,178) and value != '';
update customer_address_entity_varchar set value = '' where attribute_id in (31,175) and (value REGEXP '^[A-Za-z]+$' OR value like ('%@%'));
@trabulium
trabulium / simple_orphaned_products
Last active August 22, 2018 04:11
Magento 1: Find orphaned simple products with no parent configurable
select
type_id,sku, cpev.value,
CASE when cpei2.value = 1 THEN "Enabled" ELSE "Disabled" END
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_int cpei on cpei.`entity_id` = a.entity_id AND cpei.attribute_id = '91' #visibility
left join catalog_product_entity_int cpei2 on cpei2.`entity_id` = a.entity_id AND cpei2.attribute_id = '84' #status
left join catalog_product_entity_varchar cpev on cpev.`entity_id` = a.entity_id AND cpev.attribute_id = '60' #name
where
@trabulium
trabulium / clear_amp_cache.php
Created April 30, 2019 07:50
php script to Bulk Update AMP cache to clear AMP urls
<?php
function urlsafe_b64encode($string) {
return str_replace(array('+','/','='),array('-','_',''), base64_encode($string));
}
$ampBaseUrl="https://www-example-com-au.cdn.ampproject.org";
$file = fopen("urls.txt", "r") or exit("Unable to open file!");
@trabulium
trabulium / nema17_chatGPT_2nd_attempt
Last active February 3, 2023 04:51
ChatGPT output of an adaptor plate for a Nema17 stepper motor for FreeCAD
import FreeCAD
import Part
def create_adapter_plate():
# Define Nema17 dimensions
width = 42.3
length = 42.3
bolt_diameter = 4.0
shaft_diameter = 5.0
height = 10.0