How to Retrieve Data from customer_entity_varchar Table in Magento

customerdatabasemagento-enterprisePHP

I've created a customer attribute(file upload field) in the back end of magento: Customers > Manage Customer Attributes.

Now I want to show that this file has been uploaded in the customer's account center.

I can dump the attribute by:

$fileUpload = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'file_upload_code');
echo "<pre>";
print_r($fileUpload->getData());
echo "</pre>";

I can also see the file path that is being saved into the customer_entity_varchar table after a successful upload. But, I can't seem to figure out how to target that table. Each attempt at wording a search on google tends to bring up those attempting to pull data with SQL queries instead of using models.

I just want to do something such as:

$customer = Mage::getSingleton('customer/session')->getCustomer();
$fileUpload = Mage::getModel(customer/entity_varchar)->load($customer->getId())->getFileUpload();

Best Answer

Try this:

$customer = Mage::getSingleton('customer/session')->getCustomer();
echo $customer->getFileUploadCode();

OR

$customer = Mage::getSingleton('customer/session')->getCustomer();
$customerData = Mage::getModel('customer/customer')->load($customer->getId());
echo $customerData->getFileUploadCode();
Related Topic