Fatal Error Call To Undefined Function Getid In
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of call to a member function getid() on a non-object magento this site About Us Learn more about Stack Overflow the company Business fatal error: call to a member function getid() on null in magento Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask call to a member function getid() on a non-object php Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign call to a member function on a non-object in php up Fatal error: Call to a member function getId() on null in doctrine up vote 2 down vote favorite I have a error saying that, Fatal error: Call to a member function getId() on null. but how can i check the element, here is my code $infoArray['groupId'] = $info->getId(); $infoArray['name'] = $info->getName(); $infoArray['addressLine1'] = $info->getAddressLine1(); $infoArray['addressLine2'] = $info->getAddressLine2(); $infoArray['isActive'] = $info->getActive(); $infoArray['countryId'] = $info->getCountry()->getId(); //Here is my error line $infoArray['countryName'] = $info->getCountry()->getName(); $infoArray['stateId'] = $info->getState()->getId(); $infoArray['stateName'] = $info->getState()->getName(); $infoArray['cityId'] = $info->getCity()->getId(); $infoArray['cityName'] = $info->getCity()->getName(); $infoArray['areaId'] = $info->getArea()->getId(); $infoArray['areaName'] = $info->getArea()->getName(); $infoArray['zipcode'] = $info->getZipcode(); php symfony2 doctrine2 zend-framework2 share|improve this question asked Feb 3 at 18:33 user3929758 100111 Well, your $info object seems to return null from the getCountry() object. So you need to check with null !== $info->getCountry() or something similar first that you get the expected object back before trying to call any method. –xabbuh Feb 3 at 18:35 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted Replace the line by : $infoArray['countryId'] = $info->getCountry() ? $info->getCountry()->getId() : null; Do the same for each line corresponding to an association (which can be null), and null will be returned if the object is null. share|improve this answer edited Feb 3 at 18:47 answered Feb 3 at 18:39 chalasr 7,3102533 $infoArray['countryId'] = $info->getCountry() ?: $info->getCountry()->getId(); is not working for me, instead $infoArray['countryId'] = $info->getCountry() ? $info->getCountry()->getId() : ''; working for me –user3929758 Feb 3 at 18:46 I've edited
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like http://stackoverflow.com/questions/35184950/fatal-error-call-to-a-member-function-getid-on-null-in-doctrine you, helping each other. Join them; it only takes a minute: Sign up Fatal error: Call to a member function getId() on a non-object in… Magento Problem up vote 2 down vote favorite 1 I'm trying to setup ZetaPrint on a website. On one of the last steps, I have to do ZetaPrints templates synchronization profile, http://stackoverflow.com/questions/5943387/fatal-error-call-to-a-member-function-getid-on-a-non-object-in-magento-pro on System > Import/Export > Advanced Profiles But When I do the "Add new profile" I get this error: Fatal error: Call to a member function getId() on a non-object in /nfs/c06/h02/mnt/93577/domains/cannafresh.com/html/store/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php on line 117 The file is the original one from magento, I can't figure out the error... can anyone help me? Here's the whole code below: _title($this->__('System')) ->_title($this->__('Import and Export')) ->_title($this->__('Profiles')); $profileId = (int) $this->getRequest()->getParam($idFieldName); $profile = Mage::getModel('dataflow/profile'); if ($profileId) { $profile->load($profileId); if (!$profile->getId()) { Mage::getSingleton('adminhtml/session')->addError('The profile you are trying to save no longer exists'); $this->_redirect('*/*'); return false; } } Mage::register('current_convert_profile', $profile); return $this; } /** * Profiles list action */ public function indexAction() { $this->_title($this->__('System')) ->_title($this->__('Import and Export')) ->_title($this->__('Advanced Profiles')); if ($this->getRequest()->getQuery('ajax')) { $this->_forward('grid'); return; } $this->loadLayout(); /** * Set active menu item */ $this->_setActiveMenu('system/convert'); /** * Append profiles block to content */ $t
a quick overview of the site Help Center Detailed answers to any questions http://magento.stackexchange.com/questions/60845/strange-error-call-to-undefined-function you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Magento Questions Tags Users Badges Unanswered Ask Question _ Magento Stack Exchange is a question and answer site call to for users of the Magento e-Commerce platform. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Strange error, call to undefined function up vote 0 down vote favorite call to a Here is my controller class T2_Store_IndexController extends Mage_Core_Controller_Front_Action { public function indexAction() { $this->loadLayout(); $this->renderLayout(); } public function registerAction() { $data = $this->getRequest()->getParams(); //$data['root_category_id'] = createRootCategory($data); //$firephp->log($data); //var_dump($data);die(); try { createNewStore($data); } catch (Exception $e) { echo $e->getMessage(); } $this->_redirect('store/index'); } public function createNewStore($data) { Mage::registry('isSecureArea'); $multiWebEnable = Mage::getStoreConfig('web/multi_web_general/multi_web'); //#add Website /** @var $website Mage_Core_Model_Website */ $website = Mage::getModel('core/website'); $website->setCode($data['store_url']) ->setName($data['store_name']) ->save(); //#add StoreGroup /** @var $storeGroup Mage_Core_Model_Store_Group */ $storeGroup = Mage::getModel('core/store_group'); $storeGroup->setWebsiteId($website->getId()) ->setName($data['store_name']) ->setRootCategoryId($data['root_category_id']) ->save(); //#add Store /** @var $store Mage_Core_Model_Store */ $store = Mage::getModel('core/store'); $store->setCode($data['store_url'] . '_default') ->setWebsiteId($storeGroup->getWebsiteId()) ->setGroupId($storeGroup->getId()) ->setName($data['store_name']) ->setIsActive(1) ->save(); } public function createRootCategory($data) { Mage::registry('isSecureArea'); // Create category object $category = Mage::getModel('catalog/category'); $category->setStoreId(0); $rootCategory['name'] = $data['store_name']; $rootCategory['path'] = "1"; $rootCategory['display_mode'] = "PRODUCTS"; $rootCategory['is_active'] = 1; $category->addData($rootCategory); try { $category->save(); $rootCategoryId = $category->getId(); return $rootCategoryId; } catch (Exception $e) { echo $e->getMessage(); } } } And whenever I submit the form to registerAction() I will r