I am working in Drupal and Magento Integration
Whenever i try to get session data using this code
require_once $_SERVER['DOCUMENT_ROOT'] . "/mage1/app/Mage.php";
umask(0);
Mage::app("default");
$session = Mage::getSingleton("customer/session");
if ($session->isLoggedIn()) {
$block['content'] .= $session->getCustomer()->getName();
#var_dump($session->getData());
}
else {
$block['content'] = t('User not logged in');
}
it fails to fetch the data.
But when i run this from independent php code it works fine.
But magento's catalog objects are running perfectly inside Drupal
What could be the problem. Any suggestions
Am using D7
EDIT
require_once $_SERVER['DOCUMENT_ROOT'] . "/mage1/app/Mage.php";
umask(0);
Mage::app();
Mage::app()->getTranslator()->init('frontend');
Mage::getSingleton('core/session', array('name' => 'frontend'));
// switch off error reporting
error_reporting(E_ALL & ~ E_NOTICE);
// Brands category => ID = 101
$brand = Mage::getModel('catalog/category')->load('4');
$brands = $brand->getChildrenCategories();
foreach ($brands as $node) {
$items[] = array(
'data' => t($node['name'])
);
}
$block['content'] .= theme('item_list', array(
'items' => $items
));
This is the code i use to get the catalog products from magento and display in drupal I don't use any package for that.This is working perfectly.
session_set_save_handler()
, etc) and the Magento module includes code to marry the two. Just a guess – give us more info and I'll try to help.