I not able to get the customersID am I calling it correctly with Mage::getModel
$customer = Mage::getModel('customer/customer')
->setWebsiteId(2)
->load($this->getRequest()->getParam('customer'));
$customer_id = $customer->getId();
$sku = 'BOX3151';
$sql = "SELECT sfoi.item_id FROM sales_flat_order_item sfoi INNER JOIN sales_flat_order sfo
ON sfo.entity_id = sfoi.order_id WHERE sfo.customer_id = '$customer_id' AND sfoi.sku = '$sku'";
$read_db = Mage::getSingleton('core/resource')->getConnection('core_read');
$result = $read_db->fetchAll($sql);
$total_rows = count($result);
if($total_rows >= 1):
echo ' Found ';
else:
echo ' Empty ';
endif;
endif;
CodePudding user response:
Please check for available data in $this->getRequest()->getParam('customer')
if you have $customerId there you can use the load() method.
$customer = Mage::getModel('customer/customer')
->setWebsiteId(2)
->load($customerId)
also you can get customer object by $email.
$customer = Mage::getModel('customer/customer')
->setWebsiteId(2)
->loadByEmail($email);
CodePudding user response:
<?php
$email = "[email protected]";
$customer = Mage::getModel("customer/customer")->setWebsiteId(Mage::app()->getWebsite()->getId())->loadByEmail($email);
//use
echo $customer->getId();
echo $customer->getEmail();
echo $customer->getFirstname();
?>