Skip to content

Get new instance of MagentoFrameworkAppResourceConnection or unset MappedTables before query

So I’m facing an error in my custom query.

Multiple queries is being run to get category tree and for each category I’m mapping a table to temp table. example –

// $this->resource is object of MagentoFrameworkAppResourceConnection
$indexTable = $this->resource->getTableName("main_table");
$indexTableTmp = $this->resource->getTableName("my_temp_table");

$this->resource->setMappedTableName($indexTable, $indexTableTmp);

Now in the for loop when i try to get the table name again using –

$indexTable = $this->resource->getTableName("main_table");

I’m getting the mapped name and not the original name. I want to get the original name at start of forloop.
Is there a way to get new object of MagentoFrameworkAppResourceConnection class or to unset the mapped table names at start of forloop.

Thanks in Advance!