Answer the question
In order to leave comments, you need to log in
How to execute php file from php function?
Hello
There is a file https: //test.loc/sales/save.php
When we run it in the browser, everything works fine. There are certain manipulations with the database (adding data)
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->IncludeComponent(
"bitrix:get.sales",
"save",
Array( ),
false
);
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");
function refreshDiscountSales ($primary, $fields) {
include($_SERVER["DOCUMENT_ROOT"]."/sales/save.php");
}
Answer the question
In order to leave comments, you need to log in
For good reason, you need to take the save code out of the component, so that it is not tied to an http request, but accepts data as parameters. And this code must be called from the component and from your function.
Well, as a matter of fact, you don't need to include a file, but make an http request to this page. The new versions of Bitrix have such a thing as HttpClient. At the very least, you can always use curl for this task.
well, now you just have a function, you need to call it after some actionsrefreshDiscountSales();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question