Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6649917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:49:52+00:00 2026-05-26T00:49:52+00:00

I’m working on a script that will create or update products in my catalog.

  • 0

I’m working on a script that will create or update products in my catalog.
The script works fine when the product needs to be created, but it fails when the product already exists in the database giving me (many times) the following messages :

2011-09-30T08:00:53+00:00 ERR (3): Recoverable Error: Argument 3
passed to
Mage_Catalog_Model_Resource_Eav_Mysql4_Abstract::_canUpdateAttribute()
must be an array, null given, called in …
2011-09-30T08:00:53+00:00
ERR (3): Recoverable Error: Argument 3 passed to
Mage_Eav_Model_Entity_Abstract::_canUpdateAttribute() must be an
array, null given, called in …
2011-09-30T08:00:53+00:00 ERR (3):
Warning: array_key_exists() [function.array-key-exists]: The
second argument should be either an array or an object in …

I’ve been looking at the method quoted in the message, but I can’t find any reason why the script fails.
The script first try to load a product using :

$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);

and then test if the product was retrieved using a simple if(!$product) { //creation }.
All the code that follow the if statement is shared for creation or update and consists of setter calls on product object.

Here is the code I use :

$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
if(!$product) {
    // the product doesn't exist yet
    $product = new Mage_Catalog_Model_Product();
    $product->setSku($sku);
    $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
    $product->setCreatedAt(strtotime('now'));
}
// setters calls
$product->setTeinte(trim((string)$record->web_teinte));
// ...
// finally save the product
$product->save();

Maybe someone has already faced the same problem.
Any help is welcome ! Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:49:53+00:00Added an answer on May 26, 2026 at 12:49 am

    Chances are, in your “setter calls” you are trying to set something that cannot be directly set on $product. It could even be the “setTeinte” as I am not sure what that is trying to set. But as we cannot see all your code, it is a little difficult to say, so as I guide, take a look at the code below, which sets some information directly on the product and then stock levels. It does therefore, illustrate how certain data has to be set. I hope it helps.

    $SKU = (string)$XMLproduct->Sku;
    $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$SKU);
    
    if ($product) {
        //Product found, so we need to update it in Magento.
    
        $product->setName((string)$XMLproduct->Name);
        $product->setPrice((real)$XMLproduct->SalePrice);
        //$product->setDescription((string)$XMLproduct->LongDescription);
        //$product->setShortDescription((string)$XMLproduct->Description);
    
        $product->save();
    
        $productId = $product->getId();
        $stockItem =Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
        $stockItemId = $stockItem->getId();
    
        $stockItem->setData('manage_stock', 1);
        $stockItem->setData('qty', (integer)$XMLproduct->QtyInStock);
    
        $stockItem->save();
    
        echo $SKU," Updated: Name: '",(string)$XMLproduct->Name,"', Price: ",(real)$XMLproduct->SalePrice,", Stock level: ",$XMLproduct->QtyInStock,PHP_EOL;
    
        $updated++;
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.