/** * get item params for view push * * @param int $id * @param bool $more * @return array */ public static function getItemArray($id, $more = false) { if (isset(self::$itemArraysMoreCache[$id])) { return self::$itemArraysMoreCache[$id]; } if (isset(self::$itemArraysCache[$id]) && !$more) { return self::$itemArraysCache[$id]; } $libProduct = new \CCatalogProduct(); $libIBlockElem = new \CIBlockElement(); $libPrice = new \CPrice(); $item = $libProduct->GetByID($id); // maybe we have complex item, let's find its first child entry if ($item === false) { $list = $libIBlockElem->GetList(array('ID' => 'ASC'), array('PROPERTY_CML2_LINK' => $id)); if ($itemBlock = $list->Fetch()) { $item = $libProduct->GetByID($itemBlock['ID']); } else { return null; // c'est la vie } // now $item points to the earliest child } else { // we have simple item or child $itemBlock = $libIBlockElem->GetByID($id)->Fetch(); $itemFull = $libProduct->GetByIDEx($id); if (!empty($itemFull['PROPERTIES']['CML2_LINK']['VALUE'])) { $id = $itemFull['PROPERTIES']['CML2_LINK']['VALUE']; } // set id of the parent if we have child } $return = array('item_id' => intval($id)); if (empty($item)) { return null; } // Get categories $categories = array(); $item_categories = CIBlockElement::GetElementGroups($id, true); while ($category = $item_categories->Fetch()) { $categories[] = $category['ID']; } $return['categories'] = $categories; $has_price = false; $return['price'] = self::getFinalPriceInCurrency($return['item_id'], self::getSaleCurrency()); if (!empty($return['price'])) { $has_price = true; } if (isset($item['QUANTITY'])) { $quantity = $item['QUANTITY'] > 0; $return['is_available'] = $quantity && $has_price ? 1 : 0; } if (Options::getRecommendNonAvailable()) { $return['is_available'] = 1; } if ($more) { $libMain = new \CMain(); $libFile = new \CFile(); $itemFull = $libProduct->GetByIDEx($id); $host = ($libMain->IsHTTPS() ? 'https://' : 'http://') . SITE_SERVER_NAME; $return['name'] = $itemFull['NAME']; $return['url'] = $host . $itemFull['DETAIL_PAGE_URL']; $picture_id = Data::getProductPhotoId($id); if ($picture_id !== null) { $return['image_url'] = $host . $libFile->GetPath($picture_id); } self::$itemArraysMoreCache[$id] = $return; } else { self::$itemArraysCache[$id] = $return; } return $return; }
<div style="margin-top: 60px;"> <table> <tr> <td style="padding-left: 0"> <label for="REES46_recommend_count"><?= GetMessage('REES_OPTIONS_RECOMMEND_COUNT') ?></label> </td> <td style="padding-left: 10px"> <input type="text" id="REES46_recommend_count" value="<?= \Rees46\Options::getRecommendCount() ?>" name="recommend_count" style="width: 50px"/> </td> </tr> <tr> <td style="padding-left: 0"> <label for="REES46_recommend_nonavailable"><?= GetMessage('REES_OPTIONS_RECOMMEND_NONAVAILABLE') ?></label> </td> <td style="padding-left: 10px"> <input type="checkbox" id="REES46_recommend_nonavailable" value="1" <?php if (\Rees46\Options::getRecommendNonAvailable()): ?>checked="checked"<? endif ?> name="recommend_nonavailable" style="margin: 0"/> </td> </tr> </div> <?php $tabControl->BeginNextTab(); ?> <div> <label for="REES46_img_width"><?= GetMessage('REES_OPTIONS_IMAGE_SIZE') ?></label> <br/> <input type="text" id="REES46_img_width" value="<?= \Rees46\Options::getImageWidth() ?>" name="image_width" style="width: 50px"/> <label for="REES46_img_height">x</label> <input type="text" id="REES46_img_height" value="<?= \Rees46\Options::getImageHeight() ?>" name="image_height" style="width: 50px"/> </div> <div style="margin-top: 40px; display: none;">