Skip to content

Instantly share code, notes, and snippets.

@peterjaap
Created September 24, 2014 12:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save peterjaap/d4cefcaac36084a0a896 to your computer and use it in GitHub Desktop.
Save peterjaap/d4cefcaac36084a0a896 to your computer and use it in GitHub Desktop.
Magento SQL query to attach products that are not added to a website to the default website (id 1)
INSERT INTO catalog_product_website
(product_id, website_id)
(SELECT catalog_product_entity.entity_id, '1'
FROM catalog_product_entity LEFT JOIN catalog_product_website ON catalog_product_entity.entity_id = catalog_product_website.product_id
GROUP BY catalog_product_entity.entity_id
HAVING COUNT(catalog_product_website.product_id) = 0
ORDER BY sku DESC)
@arnoudhgz
Copy link

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment