Magento News

 

1.2.1.2 catalog/product product->save() undefined index Type.php line 71

I have used nearly the same code for creating product for months now. All the sudden I get the following error:


PHP Fatal error:  Uncaught exception 'Exception' with message 'Notice: Undefined index:    in /var/www/rkworkwear/app/code/core/Mage/Catalog/Model/Product/Type.php on line 71' in /var/www/rkworkwear/app/code/core/Mage/Core/functions.php:246
Stack trace
:
#0 /var/www/rkworkwear/app/code/core/Mage/Catalog/Model/Product/Type.php(71): mageCoreErrorHandler(8, 'Undefined index...', '/var/www/rkwork...', 71, Array)
#1 /var/www/rkworkwear/app/code/core/Mage/Catalog/Model/Product.php(134): Mage_Catalog_Model_Product_Type::factory(Object(Mage_Catalog_Model_Product))
#2 /var/www/rkworkwear/app/code/core/Mage/Catalog/Model/Product.php(303): Mage_Catalog_Model_Product->getTypeInstance()
#3 /var/www/rkworkwear/app/code/core/Mage/Core/Model/Abstract.php(249): Mage_Catalog_Model_Product->_beforeSave()
#4 /home/rkadmin/scripts/carhartt/init_items.php(10): Mage_Core_Model_Abstract->save()
#5 {main}
  
thrown in /var/www/rkworkwear/app/code/core/Mage/Core/functions.php on line 246


$product Mage::getModel('catalog/product');

        $product->setWebsiteIds(array('1'));
        
$product->setAttributeSetId(4);
        
$product->setSku($arg_data['sku']);
        
$product->setType('Simple Product');
        
$product->setName($arg_data['name']);
        
$product->setDescription('[description]');
        
$product->setShortDescription('[short_description]');
        
$product->setPrice($arg_data['price']);
        
$product->setWeight($arg_data['weight']);
        
$product->setStatus(1);
        
$product->setTaxClassId(2);
        
$product->setCategoryIds($arg_data['category_ids']);
        
$product->setVisibility(4);

$product->save();

I assume some functionality deep down in the core changed how a product is created? Any ideas where the undefined index is? I followed list of files the exception spit out and it deals with setting the product type, but I can’t get anywhere with this.

1.2.1.2 catalog/product product->save() undefined index Type.php line 71

Possibly Related Posts:


 

Leave a Reply