M
M
Maxim Grechushnikov2014-08-15 19:00:34
Yii
Maxim Grechushnikov, 2014-08-15 19:00:34

Yii2: How to implement Bitrix?

The task is to unite these two FWs in one place.
Bitrix is ​​responsible for the storefront, Yii2 is responsible for processing data from suppliers and preparing data in the database for Bitrix.
Created a model in which, ideally, it would be possible to describe the main methods of working with products through the Bitrix API, but it is convenient to receive data from Yii2ActiveRecord

<?php
namespace app\models;
use app\models\partners\Merlion\Category;
use app\models\partners\Merlion\Product;
use app\models\partners\Merlion\Property;
use app\models\Vendor;

class Bitrix extends \yii\base\Model 
{
    private $_element = null;
    
    public function init()
    {
        
            $_SERVER["DOCUMENT_ROOT"] = '/var/www';
            define("NO_KEEP_STATISTIC", true); 
            define("NOT_CHECK_PERMISSIONS", true); 
            set_time_limit(0); 
            define("LANG", "ru"); 
            require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); 
            
            global $DB;
            
            // этот блок отрабатывает норм.
            \CModule::IncludeModule("iblock");
            \CModule::IncludeModule("currency");
            \CModule::IncludeModule("catalog");
        
        // тут уже ругается, что в \ данный класс не найден. , я так понимаю, что он не инклудится корректно в prolog_before
        $this->_element = new \CIBlockElement;
  
        return parent::init();
    }
    
    public function uploadGoods()
    {
        $iblock_res = \CIBlock::GetList(array(), array('TYPE'=>'catalog_co'));
        while($iblock = $iblock_res->Fetch()){debug($iblock);}
    }
}

How to solve collision?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
@
@fewald, 2015-07-26
_

In a similar situation, get_declared_classes() showed that CIBlockElement was indeed left unloaded despite prolog_before and include_module.
I didn’t get to the bottom of the reason, I hacked dirty:
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/iblock/classes/mysql/iblockelement.php");
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/iblock/classes/mysql/iblock.php");
Not good (in case someone urgent).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question