0

we have a magento webshop, version 1.7.0.2

To promote the webshop we are also particip[ate at fairs to promote our shop and sell our products there too.

But when selling a product a the fair, the magento stock isn't being updated untill we add the order to the store. But many times the fairs are very busy, so you don't have the time to directly update the stock. And vice versa.

Is there a way, e.g. with a phone, to scan the product or enter the sku and update the magento stock right a way.

The main thing is that this could be done very quickyly, but without the need of a computer!

On the kind of fairs we only have a phone (ios and android)

Who has a solution for this?

1 Answer 1

2

It's gonna be complicated to give you a ready to go answer since this is quite a large feature you are requesting. But here goes.

One easy (and perhaps a but dirty) way to do it is create a PHP script in the Magento root directory. Below is an untested script pieced together from another import I made.

It basically gives you a form that accepts the product SKU and qty sold. When posting it the quantity is subtracted from the stock.

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
umask(0);


require_once dirname(__FILE__) . "/app/Mage.php";
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);


if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
    $post_sku = filter_input(INPUT_POST, 'sku', FILTER_SANITIZE_STRING);
    $post_qty = (int)filter_input(INPUT_POST, 'qty', FILTER_SANITIZE_STRING);


    $product_id = Mage::getModel('catalog/product')->getIdBySku( $post_sku );
    if ((int)$product_id <= 0) // Product not found
    {
        echo "<b>Product not found</b>";
    }
    else
    {
        $stock_item = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_id);
        if (!$stock_item->getId()) 
        {
            $stock_item->setData('product_id', $product_id);
            $stock_item->setData('stock_id', 1); 
        }


        $new_qty = max(0, (int)$stock_item->getQty() - $post_qty);
        if ($new_qty == 0)
        {
            echo "<b>Stock is 0</b>";
        }
        else
        {
            $stock_item->setData('qty', $new_qty);
            $stock_item->setData('is_in_stock', $new_qty ? 1 : 0);                
            $stock_item->setData('manage_stock', 1);                

            try {
                $stock_item->save();
            } catch (Exception $e) {
                echo "<b>{$e}</b>";
            }
        }
    }
}

?>
<form method="post">
    SKU: <input type="text" name="sku" value=""/><br/>
    Sold: <input type="text" name="qty" value=""/><br/>
    <input type="submit" value="Verander voorraad"/>
</form>

Still, this is not very secure since anyone can call the form and use it. You're better off building an admin extension that offers you this functionality with which you can login in the backend and then use it from your phone

Your Answer

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

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