I have a Magento 2 collection and I want to JOIN more tables to this collection's select:
public function prepareProductCollection(\Magento\Catalog\Model\ResourceModel\Product\Collection $collection) {
$query = $collection->getSelect();
$alias = 'mot';
$name = 'my_own_table';
$on = "...";
$cols = ['col1', 'col2'];
$query->joinLeft([$alias => $name], $on, $cols);
}
How can I get table name with prefix if I have $collection
variable only? This case returns table name itself (w/o prefix):
$query->getConnection()->getTableName('my_own_table')
$collection->getTable('my_own_table');