/** * Get API Key by Store ID and Customer Group ID * @param int $storeId * @param int $groupId * @return string */ public function getApiKey($storeId, $groupId) { $keyCollection = Mage::getModel('pdfpro/key')->getCollection(); $keyCollection->getSelect()->where("FIND_IN_SET('" . $storeId . "', store_ids) OR FIND_IN_SET('0', store_ids)")->where("FIND_IN_SET('" . $groupId . "', customer_group_ids)")->order('priority ASC'); $apiKey = $keyCollection->count() ? $keyCollection->getFirstItem()->getApiKey() : $this->getDefaultApiKey(); $apiKeyObj = new Varien_Object(array('api_key' => $apiKey)); Mage::dispatchEvent('ves_pdfpro_apikey_prepare', array('obj' => $apiKeyObj)); $apiKey = $apiKeyObj->getApiKey(); return $apiKey; }