13. Miscellaneous

1. Export data

A. Export data with ERP

While installing extensions, export profiles are created in order to allow you to export purchasing extension’s data. All exports are made with the CSV format.

See also

You can access to these exports from System menu > Import/export > Advanced Profiles.

Following exports are available :

  • Export Purchase Order : Exports supplier orders list
  • Export Purchase Order Products : Exports supplier orders products list
  • Export Suppliers : Exports suppliers
  • Export Contact : Exports contacts
  • Export Supply Needs: Exports supply needs (at time T).
  • Export Product : Exports products ( for buying purposes)
  • Export Stock Movement : Exports stock movements for all products
  • Export Order To Prepare Pending: Exports shipment pending customer’s orders (full order or pending order waiting to be fully received).
  • Export Order To Prepare : Exports selected customer’s orders for order preparation
  • Export Order To Prepare Items : Exports selected orders products for order preparation

To execute an export, you just have to select it from export list, to select tab ” Execute the profile ” and to click on ” Execute the profile in a popup ”.

The profile is executed and once completed, shows the path of created file.Kindly note all exports are made in the file /var/export in Magento. (please be careful, this field shall exist otherwise export will show an error).

Note

Please note, in the Embedded ERP there is no reporting system .

B. Tips Magento : export product data

1. Select a product that will be used as example to test the export, keeping in mind it must have the same attribute set than the others products you will export. In this way, you can make sure that all the attributes you want will be present in the export columns.

  1. Try to find a product which has got a maximum of attributes already filled, it will make the following steps more easy to do. Note its SKU.
  2. Go in System > Import/Export > Export.
  3. Select “Products” as Entity Type, and “CSV” as Export File Format.
  4. In the displayed attributes grid, only check the SKU checkbox. Then, click on continue at page bottom.
  5. You will get an example file with dozens of columns, and only one product : the one you choosen. Open this file with a CSV editor, like OpenOffice for example. Don’t touch to the original product, expect if you want to modify it.

7. Then, regarding the previously choosen product, enter line by line the columns you want. A lot of fields are mandatory :

sku _attribute_set _type _category _root_category _product_websites description anme short_description status taxclass_id price visibility weigth

For thoose you don’t know, just copy what you have in the initial product.

8. For inventory, you can put the same quantity than the “qty” field one, it will work with ERP. Please don’t touch to the columns you don’t really know.

  1. Don’t forget to fill the cost and price with a dot as decimal separator, because thecoma is already used as columns separator.

10. Then, go in Système > Import Export > Import Put these options : - Products - Append complex data

  1. Select your file.
  2. Click on “Check Data”. Magento will do a file-check, and will tell you if some fields are missing.
  3. If everything is alright, a button will appear, and you will be able to import the file.

2. Developer corner

Note

You will find here some of the most useful functions of ERP that you can call by program :

Force stock update on a product directly :

<?php
mage::helper('AdvancedStock/Product_Base')->updateStocks($product);

Force stock update on a product directly using a backgroundTask

<?php
mage::helper('AdvancedStock/Product_Base')->planUpdateStocksWithBackgroundTask($productId());

Refresh product availability status

<?php
mage::helper('SalesOrderPlanning/ProductAvailabilityStatus')->RefreshForOneProduct($productId);

Get data from a product availability status

<?php
$productAvailabilityStatus = mage::helper('SalesOrderPlanning/ProductAvailabilityStatus')->getForOneProduct($productId,$websiteId);
echo $productAvailabilityStatus->getMessage();
echo $productAvailabilityStatus->getBackInStockDate();
echo $productAvailabilityStatus->getSupplyDelay();
echo $productAvailabilityStatus->getAvailableQty();

Create a stock movement

<?php
$additionalDatas = array('sm_type' => 'adjustment');

mage::getModel('AdvancedStock/StockMovement')->createStockMovement($productId,
$sourceWarehouseId,
$targetWarehouseId,
$qty,
$label,
$additionalDatas);

Create a background task

<?php
mage::helper('BackgroundTask')->AddTask($title,  'helperPath',  'helperfunctionName',  $functionParameter );

To display each warehouse Qty  for a simple product

<?php
$stocks = mage::helper('AdvancedStock/Product_Base')->getStocks($_productSimple->getId());
foreach ($stocks as $stockItem) {
     echo $stockItem->getQty(); //real stock qty
     //or
     echo $stockItem->getAvailableQty(); //stock qty real available after ERP reservation
}

To display product Qty  for a simple product for a given warehouse

<?php
$stocks = mage::helper('AdvancedStock/Product_Base')->getStocks($_product->getId());
foreach ($stocks as $stockItem) {
   $stockId = $stockItem->getstock_id();
   $warehouse = mage::getModel('AdvancedStock/Warehouse')->load($stockId);
   echo $warehouse->getstock_name().' : '.$stockItem->getAvailableQty().'<br/>';
}

Refresh product availability status

<?php
mage::helper('SalesOrderPlanning/ProductAvailabilityStatus')->RefreshForOneProduct($productId);

Create an organizer

<?php
Mage::getModel('Organizer/Task')
->setot_author_user($adminUserId)
->setot_caption($title)
->setot_description('')
->setot_entity_type(MDN_Organizer_Model_Task::ENTITY_TYPE_ORDER)
->setot_entity_id($order->getId())
->setot_entity_description($helper->__('Order #%s',$order->getincrement_id()))
->setot_notify_date($date)
->setot_created_at($date)
->save();

3. ERP API

Since ERP 2.9.5.1, a new module called ERP API is provided as standard.

It open a list of features of ERP for a classic Magento API usage via SOAP.

This module has been developed as the connector for ERP Droid features.

Since ERP 2.9.5.2, we had a list of functions to export Purchase Orders, suppliers and purchase order product for Accounting needs.

Available functions :

Stock management part

  updateProductQtyByWarehouse($productId,$warehouseId,$qty)

  updateProductSelfLocationByWarehouse($productId,$warehouseId,$shelfLocation)

  updateProductWarningStockLevelByWarehouse($productId,$warehouseId,$warningStockLevel)

  updateProductIdealStockLevelByWarehouse($productId,$warehouseId,$idealStockLevel)

  skuByEan($barcode)

  productInfosByEan($ean)

  getProductImage($productId, $getBase64 = false, $resize = false, $width = 50, $height=50){

  productWarehouseList($productId)

  productPurchaseOrdersList($id, $limit)

  purchaseOrderGetSuppliedQty($productId,$si)

  purchaseOrderGetOrderedQty($productId,$si)

  productPendingSalesOrdersList($id, $limit)

  productStockMovementList($id, $limit)

  getWarehouseList()

Purchase part

  purchaseOrdersBySupplierId($supplierId,  $limit)

  purchaseOrdersProducts($purchaseOrderId,$targetWarehouseId)

  getSuppliers($supplierId = null)

  supplierList()

  getPurchaseOrders($poUpdatedAtFrom = null, $poUpdatedAtTo = null, $poSent = null,$poPaid = null, $poFinished = null)

  getPurchaseOrdersProducts($poId)

  purchaseOrderDelivery($purchaseOrderId,$targetWarehouseId, $itemsDelivered, $itemsDeliveredDefect)

Order preparation part

    getFullStockOrders($preparationWarehouseId)

    getStocklessOrders($preparationWarehouseId)

    getIgnoredOrders($preparationWarehouseId)

    getSelectedOrders($preparationWarehouseId, $operatorId)

    getOrderPreparationTabCount($preparationWarehouseId,$operatorId=1)

    getRemainToShipOrderItems($orderId, $warehouseId)

    commitPacking($orderId,$warehouseId,$operatorId = 1, $weight = null){

    addToSelectedOrders($orderId,$warehouseId,$operatorId = 1){

    removeFromSelectedOrders($orderId,$warehouseId,$operatorId = 1){

    getCurrentOrderPreparationTab($orderId,$warehouseId){

    finishSelectedOrders($ordersIds,$warehouseId,$operatorId){

    printPickingListMCC($warehouseId,$userId)

    printDocumentsMCC($warehouseId,$userId)