View Issue Details

IDProjectCategoryView StatusLast Update
0003485OXID eShop (all versions)4.05. Performancepublic2012-12-10 13:29
Reportertomas_liubinas Assigned To 
PriorityhighSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Fixed in Version4.5.9 revision 43186 
Summary0003485: Manufacturer product count cache is built too long
DescriptionIn cases when shop has many manufacturers oxUtilsCount::getManufacturerArticleCount() method crashes the shop. This happens due to fact that manufacturer product count cache in the getter is build for EVERY manufacturer and not just for the requested one.
TagsPerformance
ThemeBoth
BrowserAll
PHP Versionany
Database Versionany

Activities

tomas_liubinas

2012-02-24 15:28

reporter   ~0005809

Fixed in a way, that only requested manufacturer would be loaded in oxutilscount::setManufacturerArticleCount() method.

I include the content of this method here:


    /**
     * Saves and returns Manufacturers category article count into cache
     *
     * @param array $aCache Category cache data
     * @param string $sMnfId Unique Manufacturer ident
     * @param string $sActIdent Unique user context ID
     *
     * @return int
     */
    public function setManufacturerArticleCount( $aCache, $sMnfId, $sActIdent )
    {
        // if Manufacturer/category name is 'root', skip counting
        if ( $sMnfId == 'root' ) {
            return 0;
        }

        $oArticle = oxNew( 'oxarticle' );
        $sArtTable = $oArticle->getViewName();
        $sManTable = getViewName('oxmanufacturers');

        // select each Manufacturer articles count
        //0003485
        //$sQ = "select oxmanufacturers.oxid, count($sArtTable.oxid) from $sManTable as oxmanufacturers left outer join $sArtTable on $sArtTable.oxmanufacturerid=oxmanufacturers.oxid and $sArtTable.oxparentid = '' and ".$oArticle->getSqlActiveSnippet()." group by oxmanufacturers.oxid";
        //$sQ = "select oxmanufacturerid, count($sArtTable.oxid) from $sArtTable where $sArtTable.oxparentid = '' and oxmanufacturerid <> '' and ".$oArticle->getSqlActiveSnippet()." group by oxmanufacturerid ";
        $sQ = "select count($sArtTable.oxid) from $sArtTable where $sArtTable.oxparentid = '' and oxmanufacturerid = '$sMnfId' and ".$oArticle->getSqlActiveSnippet();

        $iValue = oxDb::getDb()->getOne( $sQ );

        $aCache[$sMnfId][$sActIdent] = (int) $iValue;

        $this->_setManufacturerCache( $aCache );

        return $aCache[$sMnfId][$sActIdent];
    }