0

mass uploading qty by sku but need to change code to "Qty for Item's Status to Become Out of Stock - 2" as thats what we have set global.

public function _updateStocks($data){
    $connection     = $this->_getConnection('core_write');
    $sku            = $data[0];
    $newQty         = $data[1];
    $productId      = $this->_getIdFromSku($sku);
    $attributeId    = $this->_getAttributeId();

    $sql            = "UPDATE " . $this->_getTableName('cataloginventory_stock_item') . " csi,
            " . $this->_getTableName('cataloginventory_stock_status') . " css
            SET
            csi.qty = ?,
            csi.is_in_stock = ?,
            css.qty = ?,
            css.stock_status = ?
            WHERE
            csi.product_id = ?
            AND csi.product_id = css.product_id";
            $isInStock      = $newQty > 0 ? 1 : 0;
            $stockStatus    = $newQty > 0 ? 1 : 0;
            $connection->query($sql, array($newQty, $isInStock, $newQty, $stockStatus, $productId));
0

What i understood is that you want to upload new QTY via excel sheet in magento.

Make an excel sheet with "sku" heading in "colA", "qty" in "colB" and "is_in_stock" in "colC"

qty is number field and is_in_stock is 0 or 1 (true false) field.

enter image description here


Once done, import via export/import or Dataflow Profiles. Hope this helps.

0

easy fix in the end.

$isInStock      = $newQty > 2 ? 1 : 0;
$stockStatus    = $newQty > 2 ? 1 : 0;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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