foreach ($allFiles as $file) { echo 'Process...' . $file . '<br>'; if (strpos($file, 'Foody_stores_of_cat') !== FALSE) { $jsonStores = global_common::readFromFile($folder . $file); //echo $jsonStores; $rootElements = json_decode($jsonStores, true); $stores = $rootElements['searchItems']; //print_r($stores); //return; echo 'Start import stores with file :' . $file . ' Count:' . count($stores) . '<br>'; foreach ($stores as $store) { //print_r($store); //return; $storeRefID = '7009-' . $store['Id']; $storeName = $store['Name']; $checkExisted = $objStore->getStoreByRefID($storeRefID); //print_r($checkExisted); ; if (!$checkExisted) { $cityName = $store['City']; $city = $objCity->getCityByName($cityName); //print_r($city); if ($city) { $cityID = $city[global_mapping::CityID]; } else { $cityID = $objCity->insert($cityName); } $districtName = $store['District']; $district = $objDistrict->getDistrictByName($districtName); //print_r($district); if ($district) { $districtID = $district[global_mapping::DistrictID];