Skip to content

Instantly share code, notes, and snippets.

@oreales
Last active November 22, 2019 19:57
Show Gist options
  • Save oreales/fdcac2b39fa93909c18b66803924af8b to your computer and use it in GitHub Desktop.
Save oreales/fdcac2b39fa93909c18b66803924af8b to your computer and use it in GitHub Desktop.
Magento: como volver a marcar el checkbox "valor por defecto" en los atributos de producto que tienen el mismo valor que la store view por defecto.
#LIMPIANDO DATETIME
#borramos los valores de atributo de la tienda 1 (o la que comparta valores con el admin / default)
#porque los valores seran los de por defecto. y los atributos cuyo valor sea NULL
DELETE FROM catalog_product_entity_datetime WHERE store_id = 1 OR `value` IS NULL;
DELETE otherStores
FROM catalog_product_entity_datetime as defaultStore
INNER JOIN catalog_product_entity_datetime as otherStores ON (defaultStore.attribute_id = otherStores.attribute_id AND defaultStore.entity_id = otherStores.entity_id)
WHERE
defaultStore.store_id = 0
AND otherStores.store_id != 0
AND defaultStore.value = otherStores.value;
#LIMPIANDO DECIMAL
#borramos los valores de atributo de la tienda 1 (o la que comparta valores con el admin / default)
#porque los valores seran los de por defecto. y los atributos cuyo valor sea NULL
DELETE FROM catalog_product_entity_decimal WHERE store_id = 1 OR `value` IS NULL;
DELETE otherStores
FROM catalog_product_entity_decimal as defaultStore
INNER JOIN catalog_product_entity_decimal as otherStores ON (defaultStore.attribute_id = otherStores.attribute_id AND defaultStore.entity_id = otherStores.entity_id)
WHERE
#excluimos precio, special price, msrp y minimal_price en esta tabla
defaultStore.attribute_id NOT IN (99,567,954,503)
AND defaultStore.store_id = 0
AND otherStores.store_id != 0
AND defaultStore.value = otherStores.value;
#LIMPIANDO INT
#borramos los valores de atributo de la tienda 1 (o la que comparta valores con el admin / default)
#porque los valores seran los de por defecto. y los atributos cuyo valor sea NULL
DELETE FROM catalog_product_entity_int WHERE store_id = 1 OR `value` IS NULL;
DELETE otherStores
FROM catalog_product_entity_int as defaultStore
INNER JOIN catalog_product_entity_int as otherStores ON (defaultStore.attribute_id = otherStores.attribute_id AND defaultStore.entity_id = otherStores.entity_id)
WHERE
defaultStore.store_id = 0
AND otherStores.store_id != 0
AND defaultStore.value = otherStores.value;
#LIMPIANDO TEXT
#borramos los valores de atributo de la tienda 1 (o la que comparta valores con el admin / default)
#porque los valores seran los de por defecto. y los atributos cuyo valor sea NULL
DELETE FROM catalog_product_entity_text WHERE store_id = 1 OR `value` IS NULL;
DELETE otherStores
FROM catalog_product_entity_text as defaultStore
INNER JOIN catalog_product_entity_text as otherStores ON (defaultStore.attribute_id = otherStores.attribute_id AND defaultStore.entity_id = otherStores.entity_id)
WHERE
defaultStore.store_id = 0
AND otherStores.store_id != 0
AND defaultStore.value = otherStores.value;
#LIMPIANDO VARCHAR
#borramos los valores de atributo de la tienda 1 (o la que comparta valores con el admin / default)
#porque los valores seran los de por defecto. y los atributos cuyo valor sea NULL
DELETE FROM catalog_product_entity_varchar WHERE store_id = 1 OR `value` IS NULL;
#consulta que borra los valores en la tabla que tienen el mismo valor que el valor por defecto
DELETE otherStores
FROM catalog_product_entity_varchar as defaultStore
INNER JOIN catalog_product_entity_varchar as otherStores ON (defaultStore.attribute_id = otherStores.attribute_id AND defaultStore.entity_id = otherStores.entity_id)
WHERE
defaultStore.store_id = 0
AND otherStores.store_id != 0
AND defaultStore.value = otherStores.value;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment