Finding products without product images using SQL (Magento 2)

Sometimes you need to find all products without assigned images in Magento 2, for example to verify that a product import or data migration is complete. The following SQL query returns products without product images:

Counting products per attribute set using SQL (Magento 2)

It can be useful to count how many products belong to each attribute set. The simplest approach in Magento 2 is the following SQL query:

The result lists the number of products assigned to each attribute set.

Checking whether a product is in stock by product ID (Magento 2)

Use the following Magento 2 snippet to check stock availability by product ID:

Et voilà!

Mage_Catalog_Block_Product::getPriceHtml causes errors with PHP 7 (Magento 1)

The following Magento 1 code no longer works with PHP 7 or later:

With PHP 7, you need to create an instance of Mage_Catalog_Block_Product and call getPriceHtml on that instance.