L
L
lie22020-07-07 10:40:42
1C-Bitrix
lie2, 2020-07-07 10:40:42

How isset works?

Good afternoon.
A normal Bitrix developer knows what the following code snippet does:

"ROOT_MENU_TYPE" => isset($arParams["ROOT_MENU_TYPE"]) ? $arParams["ROOT_MENU_TYPE"] : "left",
I have a question: is it possible to refer to the parameter of a product/selling offer in isset?

Why I ask: there is my post on the forum about the item "awaiting delivery", I somehow made the value change using if code, but this only changes in the detailed display of the product card, but it is necessary that in the catalog, etc. .places worked.
I considered different options and found in the code a call to an element and a check for IN_STOCK / NOT_IN_STOCK (this type is / is not available), and I thought when calling NOT_IN_STOCK through isset, check any parameter for yes / no and assign another phrase.

Or something similar ... although m.b. there is a variant to check for a negative value of the presence of a product and assign another phrase and an < i > element

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-07-07
@Tomio

Confused question for you, to be honest)
isset in php will return false in several situations:
1. The variable being checked does not exist
2. The variable being checked is set to Null
3. The array key being checked does not exist
4. The array key being checked is set to Null
In other cases, it will return true .
To your question "is it possible to refer to the product/offer parameter in isset?" you can answer yes.
If you need a universal check function for different components, for different templates, then it is better to implement it in the init.php file, and then execute this function in the right places.
Well, that is, in init.php you create a function, for example, isProductInStock($productId), and implement logic there that returns true or false. Then you already use this function where you need it, passing the product ID as a parameter to it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question