Esempio n. 1
0
 protected function _loadAvailableLinks(Faett_Channel_Model_Package $package, $store = null)
 {
     // load the customers purchases
     $links = Mage::getResourceModel('package/link_collection')->addFieldToFilter('product_id', $package->getId())->addOrder('version', 'desc');
     // load the customers purchases
     $purchasedLinks = $this->_loadPurchasedLinks($package, $store);
     // initialize the array for all available purchases
     $result = array();
     // assemble the data
     foreach ($links as $linkId => $link) {
         // convert the data into an array
         $l = $link->toArray(array('version', 'state', 'licence', 'release_date', 'package_name', 'licence_uri', 'state'));
         // merge the array with the customers purchases
         if (array_key_exists($linkId, $purchasedLinks)) {
             $l = array_merge($l, $purchasedLinks[$linkId]);
         }
         // attach them to the result
         $result[] = $l;
     }
     // return the result
     return $result;
 }