source/Application/Controller/Admin/ArticleExtendAjax.php
public function addCat()
    {
        $config = \OxidEsales\Eshop\Core\Registry::getConfig();
        $categoriesToAdd = $this->_getActionIds('oxcategories.oxid');
        $oxId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('synchoxid');
        $shopId = $config->getShopId();
        $objectToCategoryView = $this->_getViewName('oxobject2category');

        // adding
        if (\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('all')) {
            $categoriesTable = $this->_getViewName('oxcategories');
            $categoriesToAdd = $this->_getAll($this->_addFilter("select $categoriesTable.oxid " . $this->_getQuery()));
        }

        if (isset($categoriesToAdd) && is_array($categoriesToAdd)) {
            // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804 and ESDEV-3822).
            $database = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();

            $objectToCategory = oxNew(\OxidEsales\Eshop\Application\Model\Object2Category::class);

            foreach ($categoriesToAdd as $sAdd) {
                // check, if it's already in, then don't add it again
                $sSelect = "select 1 from " . $objectToCategoryView . " as oxobject2category where oxobject2category.oxcatnid= "
                           . $database->quote($sAdd) . " and oxobject2category.oxobjectid = " . $database->quote($oxId) . " ";
                if ($database->getOne($sSelect)) {
                    continue;
                }

                $objectToCategory->setId(md5($oxId . $sAdd . $shopId));
                $objectToCategory->oxobject2category__oxobjectid = new \OxidEsales\Eshop\Core\Field($oxId);
                $objectToCategory->oxobject2category__oxcatnid = new \OxidEsales\Eshop\Core\Field($sAdd);
                $objectToCategory->oxobject2category__oxtime = new \OxidEsales\Eshop\Core\Field(time());

                $objectToCategory->save();
            }

            $this->_updateOxTime($oxId);

            $this->resetArtSeoUrl($oxId);
            $this->resetContentCache();
            $this->onCategoriesAdd($categoriesToAdd);
        }
    }
public function addCat()
    {
        $config = \OxidEsales\Eshop\Core\Registry::getConfig();
        $categoriesToAdd = $this->_getActionIds('oxcategories.oxid');
        $oxId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('synchoxid');
        $shopId = $config->getShopId();
        $objectToCategoryView = $this->_getViewName('oxobject2category');

        // adding
        if (\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('all')) {
            $categoriesTable = $this->_getViewName('oxcategories');
            $categoriesToAdd = $this->_getAll($this->_addFilter("select $categoriesTable.oxid " . $this->_getQuery()));
        }

        if (isset($categoriesToAdd) && is_array($categoriesToAdd)) {
            // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804 and ESDEV-3822).
            $database = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();

            $objectToCategory = oxNew(\OxidEsales\Eshop\Application\Model\Object2Category::class);

            foreach ($categoriesToAdd as $sAdd) {
                // check, if it's already in, then don't add it again
                $sSelect = "select 1 from " . $objectToCategoryView . " as oxobject2category where oxobject2category.oxcatnid= "
                           . $database->quote($sAdd) . " and oxobject2category.oxobjectid = " . $database->quote($oxId) . " ";
                if ($database->getOne($sSelect)) {
                    continue;
                }

                $objectToCategory->setId(md5($oxId . $sAdd . $shopId));
                $objectToCategory->oxobject2category__oxobjectid = new \OxidEsales\Eshop\Core\Field($oxId);
                $objectToCategory->oxobject2category__oxcatnid = new \OxidEsales\Eshop\Core\Field($sAdd);
                $objectToCategory->oxobject2category__oxtime = new \OxidEsales\Eshop\Core\Field(time());

                $objectToCategory->save();
            }

            $this->_updateOxTime($oxId);

            $this->resetArtSeoUrl($oxId);
            $this->resetContentCache();
            $this->onCategoriesAdd($categoriesToAdd);
        }
    }
public function addCat ( ) { $ config = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ categoriesToAdd = $ this -> _getActionIds ( 'oxcategories.oxid' ) ; $ oxId = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'synchoxid' ) ; $ shopId = $ config -> getShopId ( ) ; $ objectToCategoryView = $ this -> _getViewName ( 'oxobject2category' ) ; // adding if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'all' ) ) { $ categoriesTable = $ this -> _getViewName ( 'oxcategories' ) ; $ categoriesToAdd = $ this -> _getAll ( $ this -> _addFilter ( "select $categoriesTable.oxid " . $ this -> _getQuery ( ) ) ) ; } if ( isset ( $ categoriesToAdd ) && is_array ( $ categoriesToAdd ) ) { // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804 and ESDEV-3822). $ database = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getMaster ( ) ; $ objectToCategory = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Object2Category :: class ) ; foreach ( $ categoriesToAdd as $ sAdd ) { // check, if it's already in, then don't add it again $ sSelect = "select 1 from " . $ objectToCategoryView . " as oxobject2category where oxobject2category.oxcatnid= " . $ database -> quote ( $ sAdd ) . " and oxobject2category.oxobjectid = " . $ database -> quote ( $ oxId ) . " " ; if ( $ database -> getOne ( $ sSelect ) ) { continue ; } $ objectToCategory -> setId ( md5 ( $ oxId . $ sAdd . $ shopId ) ) ; $ objectToCategory -> oxobject2category__oxobjectid = new \ OxidEsales \ Eshop \ Core \ Field ( $ oxId ) ; $ objectToCategory -> oxobject2category__oxcatnid = new \ OxidEsales \ Eshop \ Core \ Field ( $ sAdd ) ; $ objectToCategory -> oxobject2category__oxtime = new \ OxidEsales \ Eshop \ Core \ Field ( time ( ) ) ; $ objectToCategory -> save ( ) ; } $ this -> _updateOxTime ( $ oxId ) ; $ this -> resetArtSeoUrl ( $ oxId ) ; $ this -> resetContentCache ( ) ; $ this -> onCategoriesAdd ( $ categoriesToAdd ) ; } }
Adds article to chosen category

@throws Exception
Adds article to chosen category