Update existing products with bulk import

Payal March 5, 2019

Update existing products with bulk import

In the last blog, I shared the steps to create bulk import in Magento and in this article, I am going to explain the process to update existing products.

Here we go!

1) Begin import session with a profile & running mode; here profile is “default” & running mode is “update”. There are other available modes also i.e. “update” updates only, “xcreate” creates only.

For values other than “default” profile has to be an existing Magmi profile.

Add these lines in your script.

$dp = Magmi_DataPumpFactory::getDataPumpInstance(“productimport”);
$dp->beginImportSession(“default”, “update”);

2) Magmi profile: Create a Magmi profile with “Demo_Update” and select the options. Here is an example of Column Mapper for update:

3) Example:

<?php

define(“MAGMI_UPDATE”,”update”);
require_once(“../../inc/magmi_defs.php”);
require_once(“../inc/magmi_datapump.php”);

$products_full_file = “products_full.xml”; // local xml file name
$products_url = “http://www.demo.com/store/xmlfeed/productsxml”; //live link of products XML file
$update_profile = “Demo_Update”; //magmi profile name

$filexml = file_put_contents($products_full_file, fopen($products_url, “r”));
$products = simplexml_load_file($products_full_file);

$total_products = $products->count();

$dp = Magmi_DataPumpFactory::getDataPumpInstance(“productimport”);
$dp->beginImportSession($update_profile,MAGMI_UPDATE);

for($rows = 1 ; $rows < $total_products; $rows++){
{
$product = $products->product[$rows];
$product_sku = $product->productCode;
$price = $product->price;
$stock = $product->stock;

if(product_exists($product_sku) == 1)
{
$fields = array(
“Number” => $product_sku,
“Stock” => $stock,
“Price” => $price
);
$dp->ingest($fields);
}
}

?>

4) The above code is to update stock and price of the existing products. You can update special price, images, title description or any attribute which you want to update in bulk.

So, the shared steps will be a proven methodology to update products in a short span of time instead of following a manual lengthy approach.

Found the article useful? Share it with your friends and co-workers… Now!

If you have any queries or doubts about this topic please feel free to contact us. We are here to help you!

Lets’s Talk

About your ideas and concept