1

So, I'm using Magmi to scan through a database and update inventory for a multi-warehouse Magento setup. This is the pertinent code I'm using:

foreach ($store as $key => $sqty) {
    $sku = odbc_result($rs4, 'sku');
    $qty = odbc_result($rs4, $sqty);
    $updateItem=array("sku"=>$sku, "stock_id"=>$key, "qty"=>$qty);
    $dp->ingest($updateItem);
}

The $store array has 7 entries that indicate the $key and $qty. It runs all 7 times, but only updates the first entry.

I've narrowed it down and it looks like the issue is in the productimport_datapump.php file on line 62:

$item = array_merge($this->_defaultvalues, $item);
$diff = array_diff(array_keys($item), $this->_importcolumns);
if (count($diff) > 0) {

Since the column names are the same, it doesn't import anything past the first entry. Any idea how I can fix this? I've tried brute forcing by restarting the datapump session and starting a new instance on every foreach, but that generates some weird filename errors and obviously isn't best practice.

Thanks!

1
  • Your assertion is false, the import code is done in processDataSourceLine call,the lines depending on the if are only there to refresh missing metadata on potential new attributes if 2 items were to get different columns.
    – dweeves
    Nov 14, 2014 at 0:23

1 Answer 1

1

Gotcha. I was getting thrown off because only the data in the first loop through was getting imported. I echoed out the count($diff) and it was only showing a diff on the first go around. I mistakenly attributed my missing data with this.

Any reason why my additional data wouldn't get imported in this case though? The loop goes through the same product sku but updates qty for separate warehouses. This is what the data will look like going through:

array('sku'=>'34453xxx334', 'qty'=>15, 'stock_id'=>1)
array('sku'=>'34453xxx334', 'qty'=>2, 'stock_id'=>2)
array('sku'=>'34453xxx334', 'qty'=>4, 'stock_id'=>3)
array('sku'=>'34453xxx334', 'qty'=>6, 'stock_id'=>4)
array('sku'=>'34453xxx334', 'qty'=>1, 'stock_id'=>5)
array('sku'=>'34453xxx334', 'qty'=>0, 'stock_id'=>6)
array('sku'=>'34453xxx334', 'qty'=>23, 'stock_id'=>7)

The qty and stock_id change, but sku stays the same. Only the first stock_id gets imported.

(Side note: Thank you for all the work you have done putting this importer together, making it open source, and continually providing support. You're a god among men.)

1
  • fixed in latest git commit, the qty/stock_id update was ignored for same sku on several lines, it's now allowed.
    – dweeves
    Nov 17, 2014 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.