When 'm trying to join two tables in Magento 2, I get an empty result. This is the initial function that returns data from single table customer_entity
without any error.
\Block\Account\Message\Message.php
public function getTestCollection()
{
$page = ($this->getRequest()->getParam('p'))? $this->getRequest()->getParam('p') : 1;
$pageSize = ($this->getRequest()->getParam('limit'))? $this->getRequest()->getParam('limit') : 5;
$test = $this->_test->create();
return $collection;
}
Later I have added following lines of codes to join first table with another custom table called affiliate_account
.
$second_table_name = $this->_resource->getTableName('affiliate_account');
$collection->getSelect()->joinLeft(array('second' => $second_table_name), 'customer_entity.entity_id = second.customer_id');
This returns nothing and what is the correct way to join these two tables.