Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save DominicWatts/d21ea600b27a878205331f495ac2e8a1 to your computer and use it in GitHub Desktop.

Select an option

Save DominicWatts/d21ea600b27a878205331f495ac2e8a1 to your computer and use it in GitHub Desktop.
Mysql : Magento 2 Specific option IDs by SKU and option SKU #mysql

query

SELECT 
    p.sku AS product_sku,
    cpo.option_id,
    cpot.title,
    cpov.sku AS custom_option_sku
FROM 
    catalog_product_option AS cpo
INNER JOIN 
    catalog_product_option_title AS cpot 
    ON cpo.option_id = cpot.option_id
INNER JOIN 
    catalog_product_entity AS p 
    ON cpo.product_id = p.entity_id
LEFT JOIN 
    catalog_product_option_type_value AS cpov
    ON cpo.option_id = cpov.option_id
WHERE 
    cpov.sku = 'option-sku'
AND 
    p.sku IN ('sku1', 'sku2', 'sku3', 'sku4', 'sku5', 'sku6');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment