0

I want to compare products with tier prices from two databases. From database Magento 1 and Magento 2. Compare them to generate a list of products from Magento 1 that do not have tier prices in Magento 2 and import these products. I wrote a comparison script in js, but how can I form a query in the database to find all SKU products? Please help me with a MySQL query to select all products with tier prices for Magento 1 and Magento 2.

let test1 = ['1', '2', '3', '4/2', '5/4', '6-2'];
let test2 = ['1', '2', '3', '5/4', '4/2', '6-1', '7/2', '8-2'];


const diff = function(arr1, arr2) {
  const set = new Set(arr2);
  return arr1.filter(n => !set.has(n));
}

console.log(diff(test1, test2));

If I get all products from select catalog_product_entity_tier_price I get the only id. But I need SKU

select DISTINCT (entity_id ) from catalog_product_entity_tier_price

I tried that but its don't work

SELECT catalog_product_entity_tier_price.entity_id, catalog_product_entity.sku FROM catalog_product_entity_tier_price
INNER JOIN catalog_product_entity ON catalog_product_entity_tier_price.entity_id = catalog_product_entity.sku
1
SELECT catalog_product_entity_tier_price.entity_id, catalog_product_entity.sku FROM catalog_product_entity_tier_price
INNER JOIN catalog_product_entity ON catalog_product_entity_tier_price.entity_id = catalog_product_entity.entity_id

Check the ON clause in the above. catalog_product_entity.sku won't give you (correct) matches.

Also I would use table aliasses to make it more readable:

SELECT cpetp.entity_id, cpe.sku 
FROM catalog_product_entity_tier_price cpetp
INNER JOIN catalog_product_entity cpe ON cpetp.entity_id = cpe.entity_id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.