Croatian retailer Agrokor has agreed a deal to acquire a majority stake in Slovenian rival Mercator for EUR240m (US$320m).