N
N
nikita_falcon2020-08-08 19:43:05
1C-Bitrix
nikita_falcon, 2020-08-08 19:43:05

How to implement a parser in Bitrix?

I wrote a parser, I write all the data I need to a csv file, if I throw out files (parser) to the server, nothing works (it works only on the local machine), please tell me what to do?
I need to hang it on "Agents"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2020-08-09
@gromdron

Writing an agent is easy enough, but without specific data, it is quite difficult to consider your situation.
I can recommend general approaches to study the problem in more depth.
1) We add the developed logging mechanism.
Taking into account that windows-path and linux-path are 2 different ways of writing paths, it is better to determine the path to this file relative to $_SERVER['DOCUMENT_ROOT'] and using the realpath function The
parser should log:
- Call time
- Path to the file (where it is going to read from)
- File availability (does this file exist at all)
- File correctness (is the extension correct, are all columns present, etc.)
- [all business moments, both success and failure, including including the reason for the failure]
- Call completion time (when the work is completed)
2) Check the performance characteristics of the parser
- Is there a special. requirements (for example, bitrix sets mb_string = 2, many parsers work strictly with mb_string = 0)
- PHP version (minors must be exactly the same)
- Availability of php modules (what if you use XMLReader, which is disabled on the combat?)
3) If all above "OK", then we check if the parser works without agents (i.e. by direct call with the connection of the Bitrix core) We
check that this is not just a php code, but it is a code designed according to the rules corresponding to the agents. We look for the log file to work correctly and record the necessary information!
The documentation will be especially helpful: https://dev.1c-bitrix.ru/learning/course/index.php...
4) We create an agent and watch the progress.
If something does not work, we look at the logs and correct.
PS If your php version is higher than 7, then try-catch with Throwable will help a lot , which will catch many intercepted execution errors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question