How to ensure the current catalog of products and their availability on the website and process customer orders in accordance with internal business processes? Many online store owners face this challenge.
Integrating a single online store with the accounting system of the enterprise as a whole is easy. Implementing a ready-made integration in the boxed delivery of a CMS system and making it simple and understandable for mass use, universal for various tasks is a difficult and interesting task. This topic is about our experience in developing the integration of an online store with the popular 1C: Enterprise account system.

')
Under the cut, we will tell you how tasks were set, architecture and technical solutions were chosen, what happened as a result, how it is configured and works.
So, very often an online store is created in addition to the already existing channels: stores, retail outlets, dealer sales, and so on. And, as a rule, all channels are united by a single trading and accounting system of the enterprise or an ERP system in which the main business processes of the company are carried out:
- commodity nomenclature management;
- sales, purchases;
- finance, reporting, analytics, etc.
In this case, there is an urgent need for the online store to be integrated into a single accounting system of the enterprise or the ERP system.
The first and most important thing in the development of integration is to realize its goals and tasks to be solved. And from this already plan what, how and where to transfer. When integrating a site with an ERP system, it is usually necessary to automate the solution of three main tasks:
- ensuring uploading to the product catalog site (which is maintained in ERP) and supporting its relevance
- transfer of the order with the necessary information from the site to ERP
- informing customers about the progress of their orders, which are processed in ERP.
Everything is reasonable and simple, but, you see, many of us have witnessed how the site lives its own life, and the accounting system of its own. When ordering a product from an online store, after the manager’s call, it was found that the product is not in stock, the price does not correspond to reality, the new exchange rate or the website published the goods in the wrong configuration or with a different color picture.
Of course, the result for such a store here is only one possible: a frustrated and dissatisfied customer who is unlikely to want to return, despite the efforts of your managers.

It was back in 2007. Given the growing popularity of online stores and the growing demand for solving integration tasks, it became clear that we, as CMS system developers, had to offer our customers a
reliable and ready-made solution for such integration: easy to set up and use.
The first solution is with which accounting system to build such a ready integration? At that time, and today, the most popular solution in Russia is the
1C: Enterprise platform, most customers want to integrate their website with 1C. In terms of solving the problems of a trading company, the
1C: Trade management configuration is in the greatest demand. It was decided to integrate it with her.

Of course, everything written here also applies to solving the problem of integrating other ERP and CMS systems and sites. Approaches and ideas are important, because approaches and ideas are universal, and the code can always be adapted.
The task found specifics and we (in collaboration with 1C specialists) began work. To begin with, it was necessary to decide what the interaction architecture would be. In general, there are two boundary approaches:
- Directly referring the site to 1C
- Regular data exchange between 1C and the site
Consider the first approach - referring directly to the 1C system
When using it, the site, if necessary, requests from 1C or gives data.
It should be noted that the display of the catalog on the Internet and online ordering can be done without CMS at all, 1C has such functionality as web extensions, and not so long ago the 8.2 platform and the “managed application” technology, which make it possible to easily render 1C functionality browser. But, this is a typical example of the first approach, which has the following advantages and disadvantages for our tasks.
The advantages are obvious:
- Full relevance of the catalog on the site in real-time mode
- Instant appearance of the new order in 1C
- Quickly inform the customer about the results of order processing
As an interface between the site and 1C,
web-service technology is usually used (it is cross-platform and is the de facto standard for system integration).
Then a
web service with a set of methods is
published in 1C , the site “knocks” there from time to time: it takes or sends data. It seems everything is beautiful. BUT ... Unfortunately, such a correct and adaptable approach has not been widely adopted. And in our opinion, this is why:
1) Difficulty in setting up for mass use.
In order to publish a web service, you need to deploy a web server, register the load of the extension module, publish the web service itself. Someone will say: what kind of complexity, what nonsense and will be generally right. 1C even has the function of automatically publishing a web service in an installed web server. BUT ... life is life, it is difficult and incomprehensible to the mass consumer, to the non-programmer. And when problems begin, the web service does not work, is not visible from the outside, the alias is not registered, the user is not logged on, rights are not enough, etc. - people precipitate. In addition, if the enterprise is large enough, then the need to attract IT professionals is obvious.
2) Dependence of the site on the work of 1C
The internal accounting system may not work for various reasons: software is being updated, equipment is being replaced, backup is being restored, and so on. During these periods, your site will not be able to work correctly, as it is entirely tied to 1C. Of course, you can take these situations into account and implement some protection on the site, which would take into account the fact that the base is not working, but this is extra code, extra logic, which complicates the web system.
3) Dependence of 1C on the work site
A popular online store can have very high traffic, high peak loads, a lot of orders per unit of time. If the catalog of goods, prices and availability constantly creep into 1C, then it will be trite slowly! Web services are a convenient, technological, but far from fast way of sharing. And it even provided that the server 1C will work on decent equipment. A high peak load from the site can generally paralyze the operation of the database. Of course, the product catalog can be cached and requested from time to time, but, firstly, the first advantage of the approach is lost (permanent realtime), and secondly, the last one remains, but in our opinion, the most significant problem: the psychological ...
4) Potential threat from the site
Recall that 1C is the main accounting system of the enterprise, where all life is stored. 1: Trade management is usually integrated with accounting, personnel, etc. There are complex configurations where everything is in one bottle. Typically, the issue of security of this system is put at the forefront, and, often, is solved very simply: cutting off the cable “with the Internet” from the server in principle (physically, scientifically). Now we will put ourselves in the place of the manager, who is informed that now the site will constantly crawl in 1C for the data: record, receive, update. And even though we all know that the site climbs not directly into 1C, but through web services, which have a certain limited set of rights, it is psychologically difficult to accept. How? A site that can hack and infect a virus HAS ACCESS TO OUR 1C? Well, right now, run away ...!?

Therefore, we used the second approach.
Synchronization of data between 1C and the site on a schedule
In this concept, the site and 1C work independently, each has its own database, but during the established periods the necessary information is synchronized.
Given the above psychological point, the
site has no access to 1C ! Then, in order for everything to work, 1C should periodically access the site itself, giving or collecting information.
The advantages compared with the first approach are obvious:
- The site works independently, with its own data, does not depend on the availability of data in 1C
- 1C does not accept requests from the site, does not experience additional loads
- In case of violation of the site security, 1C security is not violated.
The current architecture has only one drawback compared with the first approach: the delay in updating data. If, for example, besides the site you are still trading at retail, then the goods that are still on the site in stock may already be out of stock. The probability of a collision, of course, is inversely proportional to the update interval. For small update intervals (a few minutes) and the average store it is very small
But, first, we accepted the assumption, which was later proved by life: for mass e-commerce, this flaw is NOT CRITICAL. The probability of such a situation is small and decreases with a decrease in the interval of exchange, and besides the mass of online stores generally do not trade on real balances, hiding the presence from visitors. And if such a situation did occur, in most cases the goods can be found quite quickly.
And secondly? And secondly, some technological solutions were used so that a relatively short update delay interval could be made without consequences.
Once again, we solved the problem of creating an integration that would be out of the box ready in the maximum number of cases. Of course, there are shops for which it is critically important, but after all, many people also don’t have cars in stock and you want tuning ?! ) And tuning already we allow ...
Speaking of transport ...
And what about web services, you ask? After all, if not on the side of 1C, then now on the side of the site they will have to publish? And on web services, we thought well, scored. And instead of them they decided to implement the exchange according to the good old HTTP protocol using the file exchange according to the
CommerceML standard.
Exchange via HTTP means that 1C accesses a script on the site and sends data files to it using the POST method. This is good because there is no need to customize anything further. Port 80 is open in most firewalls, because through it, the whole office uses the Internet and 1C very often just as well on the Internet and looks. The script on the site is included in the boxed delivery of CMS, and it also does not need to be published anywhere else.
A CommerceML is good because it is an open standard based on XML, which is specifically designed for the exchange of commercial information: catalog classifier, groups and properties of goods, goods, orders. Data transfer is possible between different systems, including between the site and back office. This standard at the time of the start of work already existed and developed. At present, version
2.05 is already available, where several pleasant innovations have appeared. And, of course, we were very pleased that such a standard was already supported at that time in 1C: Enterprise.
Examples of CommerceML files: a
file with information about products , a
file with price offers , a file with information about orders
from the site , and
to the site .
The result is the following architecture of our integration:

The structure of 1C: Enterprise includes a special module for exchange with the site, in which data exchange parameters are configured. From the corporate network, the remote site (located on some hosting site) is accessed via HTTP. The arrows leading to the site reflect the direction of requests, the initiator of which is always 1C.
1C exchange protocol with the site
The protocol is completely open, it can be modified and modified. Information about the protocol is published both in the
documentation for 1C-Bitrix , and
on the 1C website .
So, as everything said above in words looks technically:
1 http- http- :
http://<>/bitrix/admin/1c_exchange.php?type=catalog&mode=checkauth
( "\n"):
1. "success";
2. Cookie;
3. Cookie.
:
1 Cookie, "checkauth".
The next stage 1C requests some parameters from the site in order to continue the exchange:
http://<>/bitrix/admin/1c_exchange.php?type=<>&mode=init (: catalog sale, )
:
1. zip=yes/no, zip-.
2. file_limit=<>, <> - . , .
When the connection is established and the parameters are defined, the main CommerceML file exchange begins. Depending on the exchange mode 1C:
a) transmits the site data on the commodity nomenclature
http://<>/bitrix/admin/1c_exchange.php?type=catalog&mode=file&filename=< >
1C CommerceML 2, POST. "success".
b) requests customer orders from the site
http://<>/bitrix/admin/1c_exchange.php?type=sale&mode=query
CML 2. 1 :
http://<>/bitrix/admin/1c_exchange.php?type=sale&mode=success
c) reports the results of processing previously received orders to the site.
http://<>/bitrix/admin/1c_exchange.php?type=sale&mode=file&filename=< >
, POST. 1- "success". .
If an error occurred during any request, then the response of the 1C-Bitrix system will look like: the first line contains the word “failure”, and the following will describe the error that occurred during the processing of the request. If an unhandled error occurs at the core level of the product or the sql query, then the html-code from the site will be returned.
This is such a simple but reliable exchange procedure, which, I repeat, is based on three pillars:
- HTTP communication
- The initiator of the exchange is always 1C
- Open format and exchange protocol
By the way, after some time, the protocol was also supported by the developers of other CMS, and today it is essentially a de facto standard for the interaction of 1C with sites. This is very important, since initially such a task was set: not to monopolize, not to close the exchange, but to provide opportunities for further refinement, improvement of the exchange and its adaptation to specific implementations. This means that the goal of choosing the optimal architecture, in our opinion, has been achieved.
To the topic did not work out very long, that's all for today.
In the second part of the article we will tell:
- How the data transfer between 1C and the site was optimized
- How large amounts of data are transferred and overcome with typical hoster limitations
- What interface settings integration for specific tasks in both 1C and the site
- As an opportunity to refine the exchange and do non-standard things
To be continued…
Sincerely, Business Development Manager
Artem Ryabinkov