2

I tried to extract customer System->Import/Export->dataflow-Profles, due to large no of data it will stop the running and did not retrieve any csv file in the export folder.

I manually tried to get the data by a query,below is my approach for the result.

//resources 
$resource = Mage::getSingleton('core/resource');
// db access
$db_read = $resource->getConnection('core_read');
$db_write = $resource->getConnection('core_write');
// support table prefix if one is being used
$table_prefix = Mage::getConfig()->getTablePrefix();
// count the customers
$numberof_customers = $db_read->fetchOne("SELECT COUNT(*) AS num FROM {$table_prefix}customer_entity WHERE is_active = 1");

$customers = $db_read->fetchAll("SELECT cus.* FROM {$table_prefix}customer_entity AS cus WHERE cus.is_active = '1'");

for($i=0; $i < intval($numberof_customers); $i++){

  $entity_id = $customers[$i]['entity_id'];
  $items = $db_read->fetchAll("Select * from {$table_prefix}customer_entity as CE 
           JOIN {$table_prefix}customer_entity_varchar as CEV
           ON CE.entity_id=CEV.entity_id
           WHERE CEV.attribute_id=162
           AND CE.entity_id=$entity_id");//where 162 is one of attribute id for my selection
foreach ($items AS $item) {
  $cus_id =  $item['entity_id'];
  $obj = Mage::getModel('customer/customer');
  $_custom = $obj->load($cus_id);
  echo $_custom->getId()."-".$_custom->getName()."-".$_custom->getPrimaryBillingAddress()->getCity()."-".$_custom->getEmail()."-".$_custom->getMobile();

My question is , i want to retrieve gender for the specific customer in my out put. How can i retrieve gender? Great thanks for your help.. :)

1 Answer 1

2

Found here

Try this:

$this->htmlEscape($this->__(Mage::getResourceSingleton('catalog/customer')->getAttribute('gender')->getSource()->getOptionText($_custom->getGender()))))
7
  • Thank you for the help, unfortunately it did not work.
    – Mujahidh
    Commented Nov 2, 2014 at 11:10
  • What does $_custom->getGender() return?
    – Aphroz
    Commented Nov 2, 2014 at 11:15
  • it dose not return any value, I tried this too from very first.
    – Mujahidh
    Commented Nov 2, 2014 at 11:17
  • I tried that and it works: Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getOptionText($_custom->getGender()) If $_custom->getGender() doesn't return anything be sure you defined the gender in the backend
    – Aphroz
    Commented Nov 2, 2014 at 11:36
  • do you trying with the same code which i post here?
    – Mujahidh
    Commented Nov 2, 2014 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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