source/Application/Controller/Admin/CategoryMainAjax.php
public function addArticle()
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();

        $aArticles = $this->_getActionIds('oxarticles.oxid');
        $sCategoryID = $myConfig->getRequestParameter('synchoxid');
        $sShopID = $myConfig->getShopId();

        \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->startTransaction();
        try {
            $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
            $sArticleTable = $this->_getViewName('oxarticles');

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

            if (is_array($aArticles)) {
                $sO2CView = $this->_getViewName('oxobject2category');

                $oNew = oxNew(\OxidEsales\Eshop\Application\Model\Object2Category::class);
                $sProdIds = "";
                foreach ($aArticles as $sAdd) {
                    // check, if it's already in, then don't add it again
                    $sSelect = "select 1 from $sO2CView as oxobject2category where oxobject2category.oxcatnid= "
                               . $database->quote($sCategoryID) . " and oxobject2category.oxobjectid = " . $database->quote($sAdd) . "";
                    // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
                    if ($database->getOne($sSelect, false, false)) {
                        continue;
                    }

                    $oNew->oxobject2category__oxid = new \OxidEsales\Eshop\Core\Field($oNew->setId(md5($sAdd . $sCategoryID . $sShopID)));
                    $oNew->oxobject2category__oxobjectid = new \OxidEsales\Eshop\Core\Field($sAdd);
                    $oNew->oxobject2category__oxcatnid = new \OxidEsales\Eshop\Core\Field($sCategoryID);
                    $oNew->oxobject2category__oxtime = new \OxidEsales\Eshop\Core\Field(time());

                    $oNew->save();

                    if ($sProdIds) {
                        $sProdIds .= ",";
                    }
                    $sProdIds .= $database->quote($sAdd);
                }

                // updating oxtime values
                $this->_updateOxTime($sProdIds);

                $this->resetArtSeoUrl($aArticles);
                $this->resetCounter("catArticle", $sCategoryID);
            }
        } catch (Exception $exception) {
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->rollbackTransaction();
            throw $exception;
        }

        \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction();
    }
public function addArticle()
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();

        $aArticles = $this->_getActionIds('oxarticles.oxid');
        $sCategoryID = $myConfig->getRequestParameter('synchoxid');
        $sShopID = $myConfig->getShopId();

        \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->startTransaction();
        try {
            $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
            $sArticleTable = $this->_getViewName('oxarticles');

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

            if (is_array($aArticles)) {
                $sO2CView = $this->_getViewName('oxobject2category');

                $oNew = oxNew(\OxidEsales\Eshop\Application\Model\Object2Category::class);
                $sProdIds = "";
                foreach ($aArticles as $sAdd) {
                    // check, if it's already in, then don't add it again
                    $sSelect = "select 1 from $sO2CView as oxobject2category where oxobject2category.oxcatnid= "
                               . $database->quote($sCategoryID) . " and oxobject2category.oxobjectid = " . $database->quote($sAdd) . "";
                    // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
                    if ($database->getOne($sSelect, false, false)) {
                        continue;
                    }

                    $oNew->oxobject2category__oxid = new \OxidEsales\Eshop\Core\Field($oNew->setId(md5($sAdd . $sCategoryID . $sShopID)));
                    $oNew->oxobject2category__oxobjectid = new \OxidEsales\Eshop\Core\Field($sAdd);
                    $oNew->oxobject2category__oxcatnid = new \OxidEsales\Eshop\Core\Field($sCategoryID);
                    $oNew->oxobject2category__oxtime = new \OxidEsales\Eshop\Core\Field(time());

                    $oNew->save();

                    if ($sProdIds) {
                        $sProdIds .= ",";
                    }
                    $sProdIds .= $database->quote($sAdd);
                }

                // updating oxtime values
                $this->_updateOxTime($sProdIds);

                $this->resetArtSeoUrl($aArticles);
                $this->resetCounter("catArticle", $sCategoryID);
            }
        } catch (Exception $exception) {
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->rollbackTransaction();
            throw $exception;
        }

        \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction();
    }
public function addArticle ( ) { $ myConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ aArticles = $ this -> _getActionIds ( 'oxarticles.oxid' ) ; $ sCategoryID = $ myConfig -> getRequestParameter ( 'synchoxid' ) ; $ sShopID = $ myConfig -> getShopId ( ) ; \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) -> startTransaction ( ) ; try { $ database = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sArticleTable = $ this -> _getViewName ( 'oxarticles' ) ; // adding if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'all' ) ) { $ aArticles = $ this -> _getAll ( $ this -> _addFilter ( "select $sArticleTable.oxid " . $ this -> _getQuery ( ) ) ) ; } if ( is_array ( $ aArticles ) ) { $ sO2CView = $ this -> _getViewName ( 'oxobject2category' ) ; $ oNew = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Object2Category :: class ) ; $ sProdIds = "" ; foreach ( $ aArticles as $ sAdd ) { // check, if it's already in, then don't add it again $ sSelect = "select 1 from $sO2CView as oxobject2category where oxobject2category.oxcatnid= " . $ database -> quote ( $ sCategoryID ) . " and oxobject2category.oxobjectid = " . $ database -> quote ( $ sAdd ) . "" ; // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804). if ( $ database -> getOne ( $ sSelect , false , false ) ) { continue ; } $ oNew -> oxobject2category__oxid = new \ OxidEsales \ Eshop \ Core \ Field ( $ oNew -> setId ( md5 ( $ sAdd . $ sCategoryID . $ sShopID ) ) ) ; $ oNew -> oxobject2category__oxobjectid = new \ OxidEsales \ Eshop \ Core \ Field ( $ sAdd ) ; $ oNew -> oxobject2category__oxcatnid = new \ OxidEsales \ Eshop \ Core \ Field ( $ sCategoryID ) ; $ oNew -> oxobject2category__oxtime = new \ OxidEsales \ Eshop \ Core \ Field ( time ( ) ) ; $ oNew -> save ( ) ; if ( $ sProdIds ) { $ sProdIds .= "," ; } $ sProdIds .= $ database -> quote ( $ sAdd ) ; } // updating oxtime values $ this -> _updateOxTime ( $ sProdIds ) ; $ this -> resetArtSeoUrl ( $ aArticles ) ; $ this -> resetCounter ( "catArticle" , $ sCategoryID ) ; } } catch ( Exception $ exception ) { \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) -> rollbackTransaction ( ) ; throw $ exception ; } \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) -> commitTransaction ( ) ; }
Adds article to category
Creates new list

@throws Exception
Adds article to category Creates new list