Oara\Network\Publisher\AvantLink::getMerchantList PHP Method

getMerchantList() public method

public getMerchantList ( ) : array
return array
    public function getMerchantList()
    {
        $merchants = array();
        $params = array(new \Oara\Curl\Parameter('cmdDownload', 'Download All Active Merchants'), new \Oara\Curl\Parameter('strRelationStatus', 'active'));
        $urls = array();
        $urls[] = new \Oara\Curl\Request("https://classic." . $this->_domain . '/affiliate/merchants.php', $params);
        $result = $this->_client->post($urls);
        $folder = \realpath(\dirname(COOKIES_BASE_DIR)) . '/pdf/';
        $my_file = $folder . \mt_rand() . '.xls';
        $handle = \fopen($my_file, 'w') or die('Cannot open file:  ' . $my_file);
        $data = $result[0];
        \fwrite($handle, $data);
        \fclose($handle);
        $objReader = \PHPExcel_IOFactory::createReader('Excel5');
        $objReader->setReadDataOnly(true);
        $objPHPExcel = $objReader->load($my_file);
        $objWorksheet = $objPHPExcel->getActiveSheet();
        $highestRow = $objWorksheet->getHighestRow();
        for ($row = 2; $row <= $highestRow; ++$row) {
            $obj = array();
            $obj['cid'] = $objWorksheet->getCellByColumnAndRow(0, $row)->getValue();
            $obj['name'] = $objWorksheet->getCellByColumnAndRow(1, $row)->getValue();
            $merchants[] = $obj;
        }
        unlink($my_file);
        return $merchants;
    }