Example #1
0
 public function queryValues()
 {
     $result = array();
     if ($this->hasTemplates()) {
         $connection = \Freetrix\Main\Application::getConnection();
         $query = $connection->query("\n\t\t\t\tSELECT\n\t\t\t\t\tP.ID\n\t\t\t\t\t,P.CODE\n\t\t\t\t\t,P.TEMPLATE\n\t\t\t\t\t,P.ENTITY_TYPE\n\t\t\t\t\t,P.ENTITY_ID\n\t\t\t\t\t,IP.VALUE\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock_element_iprop IP\n\t\t\t\t\tINNER JOIN b_iblock_iproperty P ON P.ID = IP.IPROP_ID\n\t\t\t\tWHERE\n\t\t\t\t\tIP.IBLOCK_ID = " . $this->iblock_id . "\n\t\t\t\t\tAND IP.ELEMENT_ID = " . $this->element_id . "\n\t\t\t");
         while ($row = $query->fetch()) {
             $result[$row["CODE"]] = $row;
         }
         if (empty($result)) {
             $result = parent::queryValues();
             if (!empty($result)) {
                 $elementList = \Freetrix\Iblock\ElementTable::getList(array("select" => array("IBLOCK_SECTION_ID"), "filter" => array("=ID" => $this->element_id)));
                 $element = $elementList->fetch();
                 foreach ($result as $CODE => $row) {
                     $connection->add("b_iblock_element_iprop", array("IBLOCK_ID" => $this->iblock_id, "SECTION_ID" => intval($element["IBLOCK_SECTION_ID"]), "ELEMENT_ID" => $this->element_id, "IPROP_ID" => $row["ID"], "VALUE" => $row["VALUE"]));
                 }
             }
         }
     }
     return $result;
 }
Example #2
0
 public function loadFromDatabase()
 {
     if (!isset($this->fields)) {
         $this->fields = array();
         $select = array_values($this->fieldMap);
         $elementList = \Freetrix\Iblock\ElementTable::getList(array("select" => $select, "filter" => array("=ID" => $this->id)));
         $this->elementFields = $elementList->fetch();
         if ($this->elementFields) {
             $arCatalog = \CCatalogSKU::getInfoByProductIBlock($this->elementFields["IBLOCK_ID"]);
             if (is_array($arCatalog)) {
                 $this->skuIblockId = $arCatalog["IBLOCK_ID"];
                 $skuList = \CIBlockElement::getList(array(), array("IBLOCK_ID" => $arCatalog["IBLOCK_ID"], "=PROPERTY_" . $arCatalog["SKU_PROPERTY_ID"] => $this->id), false, false, $select);
                 while ($sku = $skuList->fetch()) {
                     $this->skuList[] = $sku;
                     foreach ($sku as $fieldName => $fieldValue) {
                         $this->fields[$fieldName][] = $fieldValue;
                     }
                 }
             }
         }
     }
     return is_array($this->fields);
 }
Example #3
0
 protected function load()
 {
     $elementList = \Freetrix\Iblock\ElementTable::getList(array("select" => array("NAME"), "filter" => array("=ID" => $this->key)));
     $element = $elementList->fetch();
     if ($element) {
         return $element["NAME"];
     } else {
         return "";
     }
 }
Example #4
0
 protected function loadFromDatabase()
 {
     if (!isset($this->fields)) {
         //Element fields
         $elementList = \Freetrix\Iblock\ElementTable::getList(array("select" => array_values($this->fieldMap), "filter" => array("=ID" => $this->id)));
         $this->fields = $elementList->fetch();
     }
     return is_array($this->fields);
 }