magento 1.9.3.7
This script stops executing after importing about 158 products, do you see what might cause it? There are 168000 products totally in the database, so it shouldn't stop like that.. (I'm moving products from cubecart to magento)
$sql = "SELECT * FROM cubecart_inventory where productId > 82300 LIMIT 2000"; $fullpath = 'media/import/'; $res = mysqli_query($db_source,$sql); $count = 0; while($obj = mysqli_fetch_object($res)) { echo "<h3>" . $obj->name . " - " . $obj->productCode . "</h3>"; try { $count++; $product = Mage::getModel('catalog/product'); $product->setSku($obj->productCode); $product->setName($obj->name); $product->setDescription($obj->description); $product->setShortDescription(''); $product->setPrice($obj->price); $product->setTypeId('simple'); $product->addImageToMediaGallery($fullpath . $obj->image, array('image','thumbnail','small_image'), false); $product->setAttributeSetId(4); $categories = get_categories($obj->cat_id,$db_source,$db_target); $product->setCategoryIds($categories); $product->setWeight($obj->prodWeight); $product->setTaxClassId(2); // taxable goods $product->setVisibility(4); // catalog, search $product->setStatus(1); // enabled $product->setTaxClassId(0); //0 = no tax // assign product to the default website $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId())); $product->setCreatedAt(strtotime('now')); $product->setStockData(array( 'use_config_manage_stock' => 0, 'is_in_stock' => 1, 'qty' => 9999, 'manage_stock' => 0, 'use_config_notify_stock_qty' => 0 )); $product->save(); } catch (Exception $e) { echo $e . "<br>"; } echo "<hr>"; }
Hi @Loginname,
Maybe you can add a try/catch to your code to handle the exception and get a better error description?
my mistake, I was missing set_time_limit(800); in the script