Ejemplo n.º 1
0
 protected function _prepareCollection()
 {
     // Build a collection representing each data feed for each website
     $collection = new Varien_Data_Collection();
     // Iterate websites and check configuration
     $websites = Mage::app()->getWebsites(false, true);
     foreach ($websites as $website) {
         // Grab id from website
         $websiteId = $website->getId();
         // Create Website Row in Grid
         if (Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/general/allfeedsenabled') == 'enabled') {
             // Lookup configuration for this site
             $feedTypes = '';
             foreach (Mybuys_Connector_Model_Generatefeeds::getFeedTypes() as $curFeedType) {
                 if (Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/feedsenabled/' . $curFeedType) == 'enabled') {
                     if (strlen($feedTypes) > 0) {
                         $feedTypes .= ', ';
                     }
                     $feedTypes .= $curFeedType;
                 }
             }
             $sftpUser = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/username');
             $sftpDestination = Mage::app()->getWebsite($websiteId)->getConfig('mybuys_datafeeds/connect/hostname');
             // Create and save grid item
             $newItem = $collection->getNewEmptyItem();
             $newItem->setData(array('id' => $website->getId(), 'website_name' => $website->getName(), 'website_code' => $website->getCode(), 'feeds' => $feedTypes, 'sftp_destination' => $sftpDestination, 'sftp_user' => $sftpUser));
             $collection->addItem($newItem);
         }
     }
     $this->setCollection($collection);
     return $this;
 }