How to get product image url in Magento 2?

In e-Commerce Site, Every Product has associated with unique images like Small Image, Base Image, thumbnail images.

Many times in custom development we need to required get product URL in Magento 2. If you are developing some feature related to images and want to retrieve the image url, You can achieve the image url by refer this article.

You can fetch all the media gallery by link, Gallery Images Collection. We can get product URL using Magento way by just simple way,

You can call any image type at above function in the second argument, There are many default image_types available.
Few of Example,
product_page_image_large (700×700)
product_page_image_medium (700×700)

You can get image type from vendor/magento/theme-frontend-blank/etc/view.xml as per your requirements.

In phtml file call like this, by just pass product id to get an image of the specific product,

Image URL with HeightxWidth equals 265×265 got as a response to the above example.

What is the use of search_query table in magento 2?

In Magento 2 search_query database table store the search query, which users have searched using the search box in Magento 2.
— query_text field in a search_query table in stores the value of search string. When User search through site, all of the search entry will be added to search_query table in query_text field.
num_results field used for Number of results for specific word in the site. That field show count of any string search in site.
— popularity field is displayed popularity of specific word in your site, the Biggest number will have the most popular search word for your site.
store_id will show search from a specific store.
There are some other field also available in search_query table but above field is the main field of a table.

You can check from the admin panel, all of the search query will be shown from Search Terms sectino.
Click on Marketing -> SEO & Search -> Search Terms
You will get all the search result grid for your site.

Error during compilation, Incompatible argument type: Required type: \Magento\Framework\DB\Adapter\AdapterInterface.

We can be resolved Compile time error by below way, The error looks like when running compilation command,

Incompatible argument type: Required type: \Magento\Framework\DB\Adapter\AdapterInterface. Actual type: string; File:
Error during compilation


From Magento 2.2.* version we need to pass full class name in__construct()  instead of $connection = null as di argument in Collection.php file.

Replace, $connection = null argument with \Magento\Framework\DB\Adapter\AdapterInterface $connection = null  in __construct() parameter.

Run again command,
php bin/magento setup:di:compile
an error will be gone.