Skip to content

Instantly share code, notes, and snippets.

@oreales
Last active August 29, 2015 14:22
Show Gist options
  • Save oreales/d4958ccbb3c5dd7e865f to your computer and use it in GitHub Desktop.
Save oreales/d4958ccbb3c5dd7e865f to your computer and use it in GitHub Desktop.
Magento: Productos Precio Especial SELECT
#SELECT special_from_date and special_to_date 77 y 78
SELECT * FROM eav_attribute WHERE attribute_code LIKE 'special%date' AND entity_type_id=4;
#SELECT el atributo special_price
SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'special_price' AND entity_type_id=4;
#SELECT productos que tienen special price ahora mismo
SELECT * FROM catalog_product_entity AS p
LEFT JOIN catalog_product_entity_datetime AS spfd USING (entity_id)
LEFT JOIN catalog_product_entity_datetime AS sptd USING (entity_id)
LEFT JOIN catalog_product_entity_decimal AS sp USING (entity_id)
WHERE
(spfd.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'special_from_date' AND entity_type_id=4) AND (spfd.value IS NULL OR spfd.value <= NOW()))
AND (sptd.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'special_to_date' AND entity_type_id=4) AND (sptd.value IS NULL OR sptd.value > NOW()))
AND (sp.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'special_price' AND entity_type_id=4) AND sp.value IS NOT NULL);
#UPDATE special_to_date a otra fecha to_date
UPDATE catalog_product_entity_datetime
SET `value`='2015-06-15 00:00:00'
WHERE
`attribute_id` = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'special_to_date' AND entity_type_id=4)
AND `value` = '2015-06-16 00:00:00';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment