Get Category Product relation table name dynamically Magento 2.

You can get the category product table name dynamically using Magento 2 Catalog module.

catalog_category_product table used for category-product relation.

The table contains entity_id, category_id, product_id and position field to manage relationships with products. Continue reading “Get Category Product relation table name dynamically Magento 2.”

How to write a SQL Safe Query using quoteInto() method magento 2?

Using a SQL quoteInto() method, Write a Query using Magento standard way with SQL Safe quoted value.

Return Type: quoteInto() always returns a string with SQL-safe quoted value placed into the original text.

quoteInto() method used in the direct SQL query for a safe quote with SQL conditions. Continue reading “How to write a SQL Safe Query using quoteInto() method magento 2?”

Write a fetchCol() Sql query in Magento 2.

Write a Mysql fetchCol() query using Magento standard way without using Model file, to Fetches the first column of all SQL result rows as an array.

Return Type: fetchCol() always return as an array. Continue reading “Write a fetchCol() Sql query in Magento 2.”