Anda tidak bisa begitu saja mengambil dan mengintegrasikan situs dengan 1C. (c) Kesenian rakyat.
Tujuan dari posting ini adalah untuk menyajikan semua informasi tentang topik dalam bahasa manusia.
Integrasi situs pada 1C-Bitrix: Manajemen Situs dan 1C adalah sumber pertanyaan dan masalah yang tidak ada habisnya. Ada 16 halaman di situs ide untuk Bitrix di bagian yang sesuai, di forum ada lebih dari 23.000 pesan tentangnya. Dalam bentuk menghubungi dukungan teknis Bitrix, bahkan ada jenis permintaan terpisah "Bertukar dengan 1C".
Diyakini bahwa integrasi 1C dan situs di Bitrix harus bekerja di luar kotak. Fungsi paling sederhana benar-benar dapat diluncurkan dalam satu atau dua jam. Tetapi Anda dapat menghabiskan 10 atau 100 jam untuk menyelesaikan pertukaran.
Penyempurnaan pertukaran situs dan 1C sudah merupakan keajaiban tingkat "ahli", menakutkan bahkan pengembang berpengalaman berjanggut. Pada artikel ini, kita akan berbicara tentang bagaimana pertukaran data antara dua monster ini terjadi dan bagaimana Anda dapat memperluas kemungkinan pertukaran ini. Artikel ini berisi banyak detail teknis pertukaran dan akan berguna terutama bagi programmer yang ingin memahami subjek.
Artikel ini akan mempertimbangkan teori umum pertukaran antara dua sistem TI dan dua pertukaran standar antara 1C dan situs di 1C-Bitrix: pertukaran barang dan pertukaran buku referensi.
Sedikit teori
— IT-. . , () ,
= (, XML, YML, JSON, CSV).
= (, HTTP, SIP, SMTP, FTP).
= . - UML Activity.
:
( FTP, CSV);
( HTTP, XML);
. ( HTTP, YML).
3 :
.
«» («») «» («»). , , . , 1 , . , .
. «1» — , - « 1», «1:» (, «1: » «1:ERP ») . - . . 1-: — «».
— .
— .
— .
1 — .
— .
— .
1
« » ( ) 4 :
1 ( «catalog»);
1 ( «reference»);
/ 1 ( «sale»);
( «sale»):
1 ;
1.
1 HTTP, . .. 1 , «» , ( POST GET) . 1 ( ). « 1 1-».
1 — , — . 1. 1 , 1 .
. 1 ( ).
.
— 1. «success», , «progress», «error» «failure», . ( ).
— CommerceML 2 . XML, , , , , (+ ).
, — HTTP. ( ) . ,
|
|
||
GET-: |
type=< > |
|
mode=checkauth |
||
Basic access : |
1 |
|
Basic access : |
1 |
|
|
|
||
: |
success < Cookie > < Cookie > sessid=<ID > <1>=<1> <2>=<2> ... |
|
: |
failure < > |
|
1 Basic access. «success», Cookie ( ), id ( type — ).
|
|
. . |
|
. . |
|
. |
1 php- : COption::SetOptionString("catalog", "DEFAULT_SKIP_SOURCE_CHECK", "Y"); COption::SetOptionString("sale", "secure_1c_exchange", "N"); |
. |
iblock . |
. , BX_SESSION_ID_CHANGE: define('BX_SESSION_ID_CHANGE', false); |
|
- , 10 . . . |
- |
|
|
||
GET-: |
type=< > |
|
mode=init |
||
sessid=<ID > |
||
Cookie: |
< Cookie >=< Cookie > |
|
|
|
||
: |
zip=<yes|no> file_limit=<> |
|
1 . « 1» .
|
|
|
|
zip |
zip-. yes — 1 , . |
yes no |
file_limit |
HTTP-. 1 , . |
>= 0 |
, 1 . «zip=yes», zip-. . .
|
|
|
. . /upload/1c_catalog/. |
(1 -> )
(type=catalog) :
;
UF- ;
;
SKU;
;
;
;
();
;
.
1 XML-, . 1 4 :
import_ — , , .
offers_ — SKU.
prices_ — .
rests_ — .
timestamp ( ). 1 timestamp .
1. ()
|
|
||
GET-: |
type=catalog |
|
mode=file |
||
sessid=<ID > |
||
filename=< > |
||
POST: |
|
|
Cookie: |
< Cookie>=< Cookie> |
|
|
|
||
: |
success |
|
: |
failure < > |
|
. file_limit (. ) POST-. , . GET- filename . , 1 .
|
|
HTTP |
1. |
< > |
apache, . |
< > |
apache, . |
2.
|
|
||
GET-: |
type=< > |
|
mode=import |
||
sessid=<ID > |
||
filename=< > |
||
Cookie: |
< Cookie>=< Cookie> |
|
|
|
||
: |
success |
|
: |
progress < > |
|
: |
failure < > |
|
— . . 11 , 1 . GET mode=import ( !), . $_SESSION[BX_CML2_IMPORT][NS]. , STEP .
2.1 (, )
|
|
||
: |
progress
|
|
: |
progress
|
|
: |
failure < > |
|
, 1 ZIP. , ( — /upload/1c_catalog/). ( STEP ).
|
|
|
PHP zip_open Zip . — . |
2.2
|
|
||
: |
progress
|
|
($_SESSION[BX_CML2_IMPORT][NS]) |
||
STEP |
0 |
|
XML ( , ) . b_xml_tree. b_xml_tree, , .
2.3
|
|
||
: |
progress
|
|
($_SESSION[BX_CML2_IMPORT][NS]) |
||
STEP |
1 |
|
b_xml_tree . PHP BX_XML_CREATE_INDEXES_IMMEDIATELY, . OnBeforeCatalogImport1C .
|
|
|
. |
2.4 ()
|
|
||
: |
progress <>% |
|
: |
progress
|
|
: |
failure < > |
|
($_SESSION[BX_CML2_IMPORT][NS]) |
||
STEP |
2 |
|
1 , b_xml_tree. , . « 1» .
|
|
|
|
2.5
|
|
||
: |
progress
|
|
: |
failure < > |
|
($_SESSION[BX_CML2_IMPORT][NS]) |
||
STEP |
3 |
|
b_xml_tree .
|
|
|
: , . |
2.6
|
|
||
: |
progress
|
|
: |
failure
< > |
|
($_SESSION[BX_CML2_IMPORT][NS]) |
||
STEP |
4 |
|
:
SKU
( CML2_: CML2_BAR_CODE, CML2_ARTICLE, CML2_ATTRIBUTES…)
UF-
-
: . 1 , .
|
|
« ». |
|
|
API, . |
( : <>) |
, XML . |
|
|
(xml_id: <>) |
|
. |
|
. . |
|
. 1 . |
|
2.7
|
|
||
: |
progress
|
|
: |
failure
< > |
|
($_SESSION[BX_CML2_IMPORT][NS]) |
||
STEP |
5 |
|
, XML . XML- XML_ID.
XML_ID , . , XML . , TIMESTAMP_X . — . .
( LEFT_MARGIN RIGHT_MARGIN).
, . .
« 1» (nginx).
1, «progress».
.
, . , XML- 20001 . 10000 .
№ / |
.. |
|
|
1 |
0 |
10000 |
|
2 |
10000 |
10000 |
|
3 |
20000 |
1 |
progress
|
, . 10000 ( TIMESTAMP_X) 10000 , -. 3- 1 .
2.8
|
|
||
: |
progress / |
|
: |
failure
< > |
|
($_SESSION[BX_CML2_IMPORT][NS]) |
||
STEP |
6 |
|
:
/ ( 1)
1 : «» ="true", .
2019 1 . , ( , ) , ( ). « 1». , .
LEFT_MARGIN RIGHT_MARGIN .
2.9 ()
|
|
||
: |
progress <> <> |
|
: |
progress
|
|
: |
failure < > |
|
($_SESSION[BX_CML2_IMPORT][NS]) |
||
STEP |
7 |
|
DONE |
, |
|
, XML . XML_ID.
XML_ID , . , XML .
, « », TIMESTAMP_X . .
TMP_ID. <>. — XML .
|
|
|
1 1 . 4.9, 4.2. |
2.10 / ()
|
|
||
: |
progress <> <> |
|
: |
progress / |
|
: |
failure < > |
|
($_SESSION[BX_CML2_IMPORT][NS]) |
||
STEP |
8 |
|
DONE |
, |
|
( 2.8 ) . “” XML ="true" ( ). , .
2019 .
2.11
|
|
||
: |
success
|
|
: |
failure < > |
|
($_SESSION[BX_CML2_IMPORT][NS]) |
||
STEP |
9 |
|
. , OnSuccessCatalogImport1C .
3.
|
|
||
GET-: |
type=< > |
|
mode=deactivate |
||
sessid=<ID > |
||
timestamp=< > |
||
Cookie: |
< Cookie>=< Cookie> |
|
|
|
||
: |
success
|
|
: |
failure
|
|
2019 , . timestamp, 1 — , .
, ( ):
, 1 . 1 .
4.
|
|
||
GET-: |
type=< > |
|
mode=complete |
||
sessid=<ID > |
||
Cookie: |
< Cookie>=< Cookie> |
|
|
|
||
: |
success
|
|
: |
failure < > |
|
. , catalog OnCompleteCatalogImport1C. OnSuccessCatalogImport1C , .
(1 -> )
(type=reference) HL-. .
— .
1. ()
2.
|
|
||
GET-: |
type=reference |
|
mode=import |
||
sessid=<ID > |
||
Cookie: |
< Cookie>=< Cookie> |
|
2.1 (, )
2.2
|
|
||
: |
progress . : <ID> |
|
: |
failure < > |
|
HL- ( ) UF-. catalog OnBeforeCatalogImportHL. , XML-. .
:
1 , ;
1 : , , , ;
, 1 , , , ;
: UF_NAME, UF_XML_ID, UF_VERSION, UF_DESCRIPTION.
|
|
< > |
1 |
< > |
1 |
XML. : < > |
1 |
.
|
|
|
10 |
XML |
20 |
XML |
110 |
XML <> |
120 |
XML <> |
210 |
UF- higloadblock |
220 |
XML <> <> |
230 |
XML <> <> |
240 |
<> <> ( : , , , ) |
250 |
UF- highload |
310 |
higloadblock |
320 |
XML <> <> |
330 |
XML <> <> <> |
2.3 ()
|
|
||
: |
success
|
|
: |
progress : <> |
|
: |
failure < > |
|
HL-.
, HL-, UF_VERSION <ID > + «#»
catalog OnSuccessCatalogImportHL. — .
.
XML.
<>
( ).
«b_» ( ).
<> . . , (sic!)
<> :
<>
XML ID
«UF_»
<>
UF-.
<>
4 : , , ,
<> :
<>
UF_XML_ID
<>
C <ID > + «#» UF_VERSION
<>
UF_NAME
UF_DESCRIPTION
«» YYYY-MM-DD HH:MI:SS.
«» true false ( ).
?
( ) 1 /bitrix/admin/1c_exchange.php. , « » /bitrix/modules/sale/admin/1c_exchange.php. , ( /bitrix/admin/1c_exchange_custom.php) 1.
, GET- ( -) . .
. , GET-, .
|
GET[type] |
|
|
|
, |
sale |
bitrix:sale.export.1c |
\CSaleOrderLoader |
/bitrix/modules/sale/general/order_loader.php |
, , , , |
catalog |
bitrix:catalog.import.1c |
\CIBlockCMLImport |
/bitrix/modules/iblock/classes/general/cml2.php |
|
|
reference |
bitrix:catalog.import.hl |
\CBitrixCatalogImportHl |
|
3 1:
, .
.
, .
:
. /bitrix/admin/1c_exchange_custom.php.
/bitrix/modules/sale/admin/1c_exchange.php.
(, bitrix:catalog.import.1c intervolga:catalog.import.1c) .
. (, \Intervolga\Custom\Exchange\Cml \CIBlockCMLImport ImportElements).
« » 1. , .
( ) , 1 - . highloadblock (, , ) .
, 1, , .
— . . , . , 2 1 .
Integrasi dengan 1C seringkali merupakan tugas yang paling sulit dalam proses pengembangan. Pemahaman yang jelas tentang proses yang terjadi di Bitrix diperlukan untuk proyek yang serius.
Penulis artikel: Anatoly Erofeev.