PHP code example of m18 / profitbase
1. Go to this page and download the library: Download m18/profitbase library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once ('vendor/autoload.php' );
m18 / profitbase example snippets
namespace M18 \Tools \Data \Profitbase ;
use M18 \Profitbase \Handlers \XML ;
use M18 \Profitbase \Models \Result \Data as ResultData ;
final class Handler extends XML
{
public function getData ($resultModel = null, bool $get_values = true) : ResultData
{
$resultModel = parent ::getData($resultModel, $get_values);
return $resultModel;
}
}
Handler::$URL = 'https://pbXXXX.profitbase.ru/export/profitbase_xml/{hash}' ;
$handler = new Handler();
$url_list = $config->url_list;
$profitbase = null ;
foreach ($url_list as $import_url)
{
try {
Handler::$URL = $import_url;
$profitbase = $handler->getData($profitbase);
}
catch (Exception $exception)
{
die ($exception->getMessage());
}
}
\M18\Profitbase\Models\Utils\RoomFields::set(array ('kitchen-space' => 'float' , 'living-space' => 'float' ));
\M18\Profitbase\Models\Utils\RoomFields::set(array ('floor' => 'string' ));
use M18 \Profitbase \Models \Utils \CustomFields ;
CustomFields::setAlias(array (
'pbcf_5b03c2b13a104' => 'bti_number' ,
'pbcf_5b03c2b141cc6' => 'bti_area' ,
'pbcf_5b03c2b146165' => 'area_wo_balcony' ,
'pbcf_5b03c2b149d47' => 'area_hallway' ,
));