Closed

Fix Magento error 1452

This project received 21 bids from talented freelancers with an average bid price of $54 USD.

Get free quotes for a project like this
Employer working
Project Budget
$10 - $30 USD
Total Bids
21
Project Description

i have this error in my magento with fresh installation. it happen when i try to add a new product with this code
$newproduct->setSku((string)$item->itemId)
->setAttributeSetId(9)# 9 is for default
->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
->setName(utf8_encode($item->title))
->setWebsiteIDs(array(1)) # Website id, 1 is default
->setDescription(utf8_encode($text))
->setShortDescription(utf8_encode($item->title))
->setMetaTitle((string)$item->subtitle)
->setMetaKeyword((string)$item->subtitle)
->setPrice($price) # Set some price
->setWeight(10)
->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->setTaxClassId(1)
->setStockData(array( "use_config_manage_stock" => "1", "original_inventory_qty" => "1", "qty"=> "99999", "use_config_min_qty" => "1", "use_config_min_sale_qty" => "1", "use_config_max_sale_qty" => 1, "is_qty_decimal" => "0", "use_config_backorders" => "1", "use_config_notify_stock_qty" => "1", "use_config_enable_qty_increments" => "1", "use_config_qty_increments" => "1", "is_in_stock" => 0 ))
->setCreatedAt(strtotime('now'));
$newproduct->save();

=================

exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento/catalog_product_entity`, CONSTRAINT `FK_CAT_PRD_ENTT_ATTR_SET_ID_EAV_ATTR_SET_ATTR_SET_ID` FOREIGN KEY (`attribute_set_id`) REFERENCES `eav_attribute_set` (`attribute_set_id`) ON DELE)' in C:\AppServ\www\magento\lib\Zend\Db\Statement\[url removed, login to view]

could somebody help please.

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online