Skip to content

Instantly share code, notes, and snippets.

@gromdron
Created April 19, 2020 13:13
Show Gist options
  • Save gromdron/f8545e0993bae6a51a183c54d59a0280 to your computer and use it in GitHub Desktop.
Save gromdron/f8545e0993bae6a51a183c54d59a0280 to your computer and use it in GitHub Desktop.
get invoice items
use \Bitrix\Main;
use \Bitrix\Sale;
use \Bitrix\Crm\Invoice;
try
{
if ( ! Main\Loader::IncludeModule('crm') )
{
throw new \Exception("CRM module not inluded");
}
if ( !Main\Loader::IncludeModule('sale') )
{
throw new \Exception("Sale module not included");
}
$invoiceId = 3;
$registry = Sale\Registry::getInstance( Invoice\Invoice::getRegistryType() );
$invoiceClass = $registry->get( Sale\Registry::ENTITY_ORDER );
$invoice = $invoiceClass::load($invoiceId);
// Получаем товары
$invoiceItems = $invoice->getBasket();
foreach ($invoiceItems as $invoiceBasketItem)
{
var_dump($invoiceBasketItem->getField('NAME'));
var_dump($invoiceBasketItem->getFinalPrice());
}
}
catch( \Exception $e )
{
var_dump($e->getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment