If you want to implement your own Inventory Loader to, for example, add Products from something inside your module?
That’s easy!
Create a file <customname>.inc.php in the folder modules/Workflow2/extends/inventoryloader/
This file must have the following structure:
<?php
namespace Workflow\Plugin\InventoryLoader;
use Workflow\InventoryLoader;
use Workflow\VTEntity;
class CustomClassName implements \Workflow\Interfaces\IInventoryLoader {
public function getAvailableLoader()
{
return array(
'loaderkey' => array( // LOADERKEY
'label' => 'Label of Loader', // LOADERLABEL
'config' => array( // LOADERCONFIG
)
),
);
}
public function getItems($config, VTEntity $context)
{
$products = array();
$products[] = array(
'module' => 'Products',
'productlabel' => 'Productlabel',
'productid' => 'productid',
'comment' => 'Comment of Product',
'quantity' => 1,
'listprice' => 12,
'discount_amount' => 0,
'discount_percent' => 0,
'taxes' => array(
1 => 19,
2 => 0
)
);
$products[] = array(
'module' => 'Products',
'productlabel' => 'Productlabel2',
'productid' => 'productid2',
'comment' => 'Comment of Product2',
'quantity' => 2,
'listprice' => 12,
'discount_amount' => 0,
'discount_percent' => 0,
'taxes' => array(
1 => 19,
2 => 0
)
);
return $products;
}
}
InventoryLoader::register(__NAMESPACE__.'\CustomClassName');
LOADERKEY | internal key of your loader to be able to register multiple loader |
LOADERLABEL | Visible Label of Inventory Loader |
LOADERCONFIG | Config, visible if Loader of selected |
The CustomClassName could be chosen like you want. It only must equal in class definition and register function in last line.
Artikel-PDF herunterladen