How to Write Select Query in Magento 2 with Standard way?

You can write a select query in Magento 2 to retrieve records from the table.

The select query can be written with best practices to avoid security breaches.

For example, You are searching for records from the core_config_data table,

Row query:

SELECT * FROM `core_config_data` WHERE `scope` = 'default' AND `path` = 'general/locale/code';

You can directly use the above string as a query and pass it to the query() method but it’s not a secure way to write a select query.

I will show you the standard Magento way to write database queries with the best secure standard Practice. Continue reading “How to Write Select Query in Magento 2 with Standard way?”

How to Get Child Configurable product Super attribute value Magento 2?

You can retrieve the Children item used super attribute label value data from the child and parent product SKU of the configurable product.

This article is useful when you are programmatically adding a Configurable product to the cart. 

Let’s take an example, You need to fetch used super attribute value of the child item, native Magento sample data configurable product name, Cassius Sparring Tank has product SKU MT12 and its child product name Cassius Sparring Tank-XL-Blue has product SKU MT12-XL-Blue. Continue reading “How to Get Child Configurable product Super attribute value Magento 2?”

How to Check if product has links_exist attribute in Magento 2?

Attribute code links_exist is available for the only Downloadable Product type in Magento 2.

You can verify if the product has links exists or not programmatically by the class, Magento\Downloadable\Model\Product\Type

Using Model class, create simple function to check links exist for the given product by $product->getData(‘links_exist’) Continue reading “How to Check if product has links_exist attribute in Magento 2?”