1. REGISTRATION REQUIREMENTS:

    Register with your xenforo.com Username then start a conversation at xenforo.com w/Bob and provide the following:
    1. Your XenForo License Validation Token
    2. The Domain Name associated with the License
    NOTE: Your account will be validated once ALL requirements are verified/met. Thank you for your patience.

Stat rebuilding after custom showcase import

Discussion in 'Showcase Support' started by Ludachris, Apr 2, 2014.

  1. Ludachris

    Ludachris Active Member AMS Premium CAS Premium RMS Premium SC Premium UBS Premium

    Hey Bob, I just did a custom import to fill our showcase section with over 10k items from vB data. It worked very well for the most part. However, I noticed that the showcase item count for each member isn't reflecting this newly imported data, nor are the showcase category counts. I only found one showcase-specific data rebuilder in the Rebuild Caches section of Tools, and it's for thumbnails. Is there another rebuilder I should run to update these two stats?

    Also, and sorry, I'm sure I can find this info by doing a bit of searching, but figured since I'm already posting a question - is there a way to change the URL structure from /showcase/ to something different relatively easily?
     
  2. Ludachris

    Ludachris Active Member AMS Premium CAS Premium RMS Premium SC Premium UBS Premium

    Never mind on that last question, I see I'll have to look into the wonderful new world of XF route filters. But the other questions still stand.
     
  3. Bob

    Bob Developer Staff Member

    SC 2.0.0 has Category, Item and Comment cache rebuilders built in now (along with thumbs).

    You'll most likely need to process these 4 methods (in order). The first will correctly construct the nested set hierarchy, the 2nd will rebuild all the Item counts for each category, the 3rd will do the same for users item count and the last one will make sure the correct username is associate with each item.

    XenForo_Model::create('NFLJ_Showcase_Model_Category')->updateNestedSetInfo();
    XenForo_Model::create('NFLJ_Showcase_Model_Category')->rebuildCategoryItemCounts();

    XenForo_Model::create('NFLJ_Showcase_Model_Item')->updateUserShowcaseCount();
    XenForo_Model::create('NFLJ_Showcase_Model_Item')->updateItemUsernameInfo();

    obviously, make sure you backup before running them.
     
  4. Ludachris

    Ludachris Active Member AMS Premium CAS Premium RMS Premium SC Premium UBS Premium

    I take it I can just add those lines to the end of the import script for the final migration? And to fix them now in my test environment I would just create a php file, add those lines, and run the script.
     
  5. Bob

    Bob Developer Staff Member

    ya, just add them to the end of the import script (as long as its within the XF framework) :) They will only work with versions older than 2.0.0 tho (the methods don't even exist in the new version).

    You can't just place that code in a raw PHP file and run it... it needs to be within the framework.

    best way to do it is just toss it into one of the controllers and then access the page..

    ie use the showcase controller like this..

    find this.... (around line 25 of the /library/NFLJ/Showcase/ControllerPublic/Showcase.php)

    PHP:
        /**
         * Displays the Showcase Index Page in Grid or List view
         *
         * @return XenForo_ControllerResponse_View
         */   
        
    public function actionIndex()
        {
    Then add this..

    PHP:
            $this->_getSCCategoryModel()->updateNestedSetInfo();
            
    $this->_getSCCategoryModel()->rebuildCategoryItemCounts();

            
    $this->_getSCItemModel()->updateUserShowcaseCount();
            
    $this->_getSCItemModel()->updateItemUsernameInfo();
    so the top of the index method would now look like this (with obviously the rest of the method still in tact..

    Code:
        /**
         * Displays the Showcase Index Page in Grid or List view
         *
         * @return XenForo_ControllerResponse_View
         */   
        public function actionIndex()
        {
            $this->_getSCCategoryModel()->updateNestedSetInfo();
            $this->_getSCCategoryModel()->rebuildCategoryItemCounts();
    
            $this->_getSCItemModel()->updateUserShowcaseCount();
            $this->_getSCItemModel()->updateItemUsernameInfo();
    
            if ($itemId = $this->_input->filterSingle('item_id', XenForo_Input::UINT))
            {
                return $this->responseReroute(__CLASS__, 'item');
            }
           
            if ($this->_routeMatch->getResponseType() == 'rss')
            {
                return $this->getGlobalRss();
            }       
           
            $layoutType = XenForo_Application::get('options')->scIndexLayoutType;
            if ($layoutType == 'modular')
            {
                return $this->responseReroute(__CLASS__, 'modular');
            }

    Then access the showcase home page and it will run those 4 methods (let it run as it might take awhile).

    once it runs, remove them.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.