Magento Fatal error: Call to a member function setData()

2.5k views Asked by At

I am helping a friend of mine move their Magento store to a new server and am now experiencing some issues.

Not sure if it makes any difference, but for a bit of background, I have placed the Magento store inside a sub-directory of their new WordPress site. I don't think this is the problem but thought I would throw that out here just in case.

The problem I am having is that when you attempt to add an item to your cart I am getting the following error:

Fatal error: Call to a member function setData() on a non-object in ...app/code/core/Mage/Sales/Model/Quote/Item.php on line 612

Here is the method being called when the error happens:

public function addOption($option)
{
    if (is_array($option)) {
        $option = Mage::getModel('sales/quote_item_option')->setData($option)
            ->setItem($this);
    }
    elseif (($option instanceof Varien_Object) && !($option instanceof Mage_Sales_Model_Quote_Item_Option)) {
        $option = Mage::getModel('sales/quote_item_option')->setData($option->getData())
           ->setProduct($option->getProduct())
           ->setItem($this);
    }
    elseif($option instanceof Mage_Sales_Model_Quote_Item_Option) {
        $option->setItem($this);
    }
    else {
        Mage::throwException(Mage::helper('sales')->__('Invalid item option format.'));
    }

    if ($exOption = $this->getOptionByCode($option->getCode())) {
        $exOption->addData($option->getData());
    }
    else {
        $this->_addOptionCode($option);
        $this->_options[] = $option;
    }
    return $this;
}

Another strange thing, I originally set up the entire site on my local machine and when adding an item to cart on the local setup Magento tells me to enable cookies, which are already enabled.

At this point I have no idea what the issue could be. I have not written a line of code in this site, nor have I modified any.

Could there be a setting that needs changed in one of the xml files possibly?

The domain of the site has not changed, only the server, and instead of being in the root directory the Magento store is now located in a subdirectory called /shop.

I changed the base url's to reflect that of course.

Any help would be very much appreciated. Thought this would be very simple as I am only migrating the site to a new server.

1

There are 1 answers

0
Alex Coloma On

When you move magento to another server you have to check that the new server acomplish with all the requirements:

  • PHP
  • php-mysql
  • php-mcrypt
  • php-hash
  • php-xml (will be required for Magento 1.4.xx)
  • php-gd
  • php-pdo
  • php-mhash
  • php-soap

    yum install php php-mysql php-mcrypt php-xml php-gd php-pdo php-mhash php-soap

You can check if everything is right with <?php phpinfo(); ?>

Also, you can try to run the setup again (you wont lose data) just deleting/renaming the file /app/etc/local.xml. Setup will detect if there is something wrong with the requirements