3

We have a prefix in our Magento DB: prefix_

Now, Magento has been working fine for years. But in one of the extension when we call the code below. Instead of printing prefix_catalog_product_index_price it prints catalog_product_index_price. The prefix_ is missing.

prefix_catalog_product_index_price exists in the database just like all the other tables.

$adapter = Mage::getResourceSingleton('core/resource')->getReadConnection();
Mage::log($adapter->getTableName('catalog_product_index_price'));

-

$adapter = Mage::getSingleton('core/resource')->getConnection('core_read');
Mage::log($adapter->getTableName('catalog_product_index_price'));

What can this be?

Why is getTableName not working? or adding the prefix?

13

Maybe it's a little bit late, but for anyone who is searching for the correct answer here it is

Mage::getSingleton('core/resource')->getTableName('customer_entity');

It will returns "yourtableprefix_customer_entity"

| improve this answer | |
2
$connection = Mage::getSingleton('core/resource');
$connection->getTableName('catalog/product_index_price')

In Catalog module config.xml Magento define this table entity is product_index_price

 <product_index_price>
     <table>catalog_product_index_price</table>
 </product_index_price>

for getting a table with prefix then try

$adapter->getTable('yourmodelprefix/entities');

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.