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; }
/** * Passes the package the serializer has to be attached. * * @param Mage_Api_Model_User $user * The user logged into the system * @param Faett_Channel_Model_Package $package * The package to serializer has to be attached to * @return void */ public function __construct(Mage_Api_Model_User $user, Faett_Channel_Model_Package $package) { Faett_Channel_Serializer_Abstract::__construct($user); $this->_package = $package->setSerializer($this); }