I’m trying to get all products using Magento SQL. I just need to do some tweaks.
If the product has a thumbnail, it should show its value and if it is null, it should show my custom text. My code below but I’m unaware about the null check conditions.
My main table: catalog_product_entity
<?php
parent::_initSelect();
$this->getSelect()
->joinLeft(
array('secondTable' => $this->getTable('catalog_product_entity_varchar')),
'main_table.entity_id = secondTable.entity_id',
'value as name'
)->where('secondTable.attribute_id = 73');
$this->getSelect()->joinLeft(
array('thirdTable' => $this->getTable('catalog_product_entity_varchar')),
'main_table.entity_id = thirdTable.entity_id',
'value as thumbnail'
)->where('thirdTable.attribute_id = 88');
$this->getSelect()->joinLeft(
array('fourthTable' => $this->getTable('catalog_product_entity_decimal')),
'main_table.entity_id = fourthTable.entity_id', // common column which available in both table
'value as price'
)->where('fourthTable.attribute_id = 77')
->group('main_table.entity_id');