M
M
MasterMike2019-06-16 23:37:54
1C-Bitrix
MasterMike, 2019-06-16 23:37:54

How to make a unique CNC at the section level?

Hello!
The question is valid for the Bitrix version > 18.
Actually, what is the question: there is an infoblock, there are sections in the infoblock, there is a CNC uniqueness check in the catalog.
But by default, the "uniqueness check" checks the CNC for the entire ifnoblock, i.e. two different sections cannot have two different items with the same CNC.
Those. the physical location of these products is different (in different sections), but the system presents them as the same (and if there is already one product in one section with this CNC, then creating a second one in another section - and displaying it - is a bummer).
Question: what and how should be done, what and how to change in which file so that the uniqueness of the CNC is checked at the section level?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Gritsuk, 2019-06-17
@winer

  • Disable the standard check for the uniqueness of the symbolic code in the IB settings.
  • Write your own function to check the character code for uniqueness within a section (eg checkElementXmlId($xmlId, $sectionId)). Check with CIblockElement::GetList
  • Write your own event handlers for OnBeforeIBlockElementAdd and OnBeforeIBlockElementUpdate . In these events, check the element's XML_ID using the previously written checkElementXmlId method. Examples of event handlers can be found at the link on the documentation pages.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question