/** * * @param string $jsonDOC * @return boolean */ public function import($jsonDOC) { //echo $jsonDOC."\n"; Yii::info("Restaurant input:" . $jsonDOC); $docObj = Json::decode($jsonDOC, true); $mappingVanue = ["_id" => "Id", "est_name" => "name", "est_add2" => false, "est_add1" => "address", "est_landmark" => "landmark", "est_phone" => false, "est_mobile" => false, "est_toll_free" => "tollfree", "est_hotel_name" => "hotelId", "est_two_price" => "priceForTwo", "est_happy_hours" => false, "est_tips" => "tips", "est_specialities" => "specialities", "est_famous_for" => "famousFor", "est_which_type" => false, "est_which_type_id" => "entityType", "est_is_featured" => false, "criticName" => false, "criticImage" => false, "critic_name" => false, "critic_review" => false, "critic_food_rate" => false, "critic_service_rate" => false, "critic_decor_rate" => false, "critic_review_date" => false, "totalAvgRatingUser" => false, "user_food_rate_avg" => false, "user_service_rate_avg" => false, "user_decor_rate_avg" => false, "user_rating_count" => false, "critic_updated_date" => false, "userReviewArr" => false, "criticReviewArr" => false, "est_review_cnt" => false, "est_tags" => false, "est_viewcount" => false, "est_rate_cnt" => false, "est_launch_date" => 'launchdate', "est_pin_code" => "pin", "zone_name" => false, "zone_label" => false, "city_name" => false, "popularity_score" => false, "is_best" => false, "is_best_priority" => false, "deals" => false, "is_table_reservation_available" => false, "online_order_flag" => false, "gourmetitup_available" => false, "logo" => false, "loc_name" => false, "est_loc_id" => "localityId", "loc_name_alias" => false, "est_grp_id" => 'chainId', "est_group" => false, "est_grp_name" => false, "est_group_count" => false, "cuisine_priorities_list" => false, "est_flag" => false, "logo" => false, "image_url" => false, "is_image" => false, "est_menu" => false, "video_link" => false, "video_data" => false, "cuisines_name" => false, "est_type_name" => false, "service_name" => false, "feature_name" => false, "total_events" => false, "guid" => "guid", "loc_name_ft" => false, "est_name_cl" => false, "est_video_present" => false, "est_status" => "status", "est_hotel_name_ft" => false, "feature_tags" => false, "whats_new_rest" => false, "whats_new_bar" => false, "est_phone_alias" => "phoneAlias", "est_is_awarded" => false, "or_total_sum" => false, "or_users_count" => false, "std_code" => false, "est_email" => "email", "establishment_website" => "website", "located_in" => false, "suggestedDishesArr" => false, "popular_dishes" => false, "suggested_dishes" => false, "created_date" => "createdOn", "modified_date" => "updatedOn", "est_city_id" => "cityId", "est_types_id" => false, "lat_lng" => false, "loc_long_lat" => false, 'gpsLat' => 'gpsLat', 'gpsLong' => 'gpsLong', "rand" => false, "georand" => false, "is_whats_hot" => false, "whats_hot_image" => false, "whats_hot_priority" => false, "popular_pubs" => 'popularpubs', "awardsArr" => false, "extrafields" => false, "facebook" => "facebook", "ip" => "ip", 'createdBy' => "createdBy", 'updatedBy' => "updatedBy", 'coverFee' => "coverFee", 'entryFee' => "entryFee", 'ladiesFee' => "ladiesFee", 'capacity' => 'capacity', 'source_id' => 'sourceId', 'zoneId' => 'zoneId', 'oldguid' => 'old_guid', 'owner_name' => 'owner', 'manager_name' => 'manager', 'desc' => 'description', 'informar_name' => 'alias', 'est_cat_id' => false, 'typesid' => false, 'crowdids' => false, 'servicesid' => false, 'featuresid' => false, 'cuisinesid' => false, 'musicids' => false, 'paymentids' => false, 'est_usp_id' => false, 'state' => 'state']; $mappingfunction = ["est_hotel_name" => function ($data, $row) { return isset($row['extrafields']['hotelid']) ? $row['extrafields']['hotelid'] : 0; }, "est_launch_date" => function ($data, $row) { return $data['sec'] > 0 ? date('Y-m-d', $data['sec']) : ''; }, 'gpsLat' => function ($data, $row) { return isset($row['loc_long_lat'][0]) ? $row['loc_long_lat'][0] : 0; }, 'gpsLong' => function ($data, $row) { return isset($row['loc_long_lat'][1]) ? $row['loc_long_lat'][1] : 0; }, 'facebook' => function ($data, $row) { return isset($row['extrafields']['facebook']) ? $row['extrafields']['facebook'] : ''; }, 'ip' => function ($data, $row) { return isset($row['extrafields']['ip']) ? $row['extrafields']['ip'] : ''; }, 'createdBy' => function ($data, $row) { return isset($row['extrafields']['created_by']) ? $row['extrafields']['created_by'] : 0; }, 'updatedBy' => function ($data, $row) { return isset($row['extrafields']['modified_by']) ? $row['extrafields']['modified_by'] : 0; }, 'coverFee' => function ($data, $row) { return isset($row['extrafields']['fee']['cover']) && $row['extrafields']['fee']['cover'] > 0 ? $row['extrafields']['fee']['cover'] : 0; }, 'entryFee' => function ($data, $row) { return isset($row['extrafields']['fee']['entry']) && $row['extrafields']['fee']['entry'] > 0 ? $row['extrafields']['fee']['entry'] : 0; }, 'ladiesFee' => function ($data, $row) { return isset($row['extrafields']['fee']['ladies']) && $row['extrafields']['fee']['ladies'] > 0 ? $row['extrafields']['fee']['ladies'] : 0; }, 'capacity' => function ($data, $row) { return isset($row['extrafields']['capacity']) && $row['extrafields']['capacity'] > 0 ? $row['extrafields']['capacity'] : 0; }, 'est_famous_for' => function ($data, $row) { return implode(', ', $data); }, 'source_id' => function ($data, $row) { return isset($row['extrafields']['source_id']) && $row['extrafields']['source_id'] > 0 ? $row['extrafields']['source_id'] : 0; }, 'est_two_price' => function ($data, $row) { return $data > 0 ? (int) $data : 0; }, 'zoneId' => function ($data, $row) { return isset($row['extrafields']['zoneid']) && $row['extrafields']['zoneid'] > 0 ? $row['extrafields']['zoneid'] : 0; }, 'oldguid' => function ($data, $row) { return isset($row['extrafields']['oldguid']) && $row['extrafields']['oldguid'] != '' ? $row['extrafields']['oldguid'] : ''; }, 'owner_name' => function ($data, $row) { return isset($row['extrafields']['owner_name']) && $row['extrafields']['owner_name'] != '' ? $row['extrafields']['owner_name'] : ''; }, 'manager_name' => function ($data, $row) { return isset($row['extrafields']['manager_name']) && $row['extrafields']['manager_name'] != '' ? $row['extrafields']['manager_name'] : ''; }, 'desc' => function ($data, $row) { return isset($row['extrafields']['desc']) && $row['extrafields']['desc'] != '' ? $row['extrafields']['desc'] : ''; }, 'informar_name' => function ($data, $row) { return isset($row['extrafields']['informar_name']) && $row['extrafields']['informar_name'] != '' ? $row['extrafields']['informar_name'] : ''; }, "state" => function ($date, $row) { switch ((int) $row['est_status']) { case 1: $ret = AppActiveRecord::STATUS_PUBLISH; break; case 0: $ret = AppActiveRecord::STATUS_DELETE; break; default: $ret = AppActiveRecord::STATUS_UNPUBLISH; break; } return $ret; }]; $data = ['media' => Import::importMediaData($docObj['extrafields']['images']['entity'], $this->imagePath), 'menu' => Import::importMediaData($docObj['extrafields']['images']['menu'], $this->menuimagePath), 'video' => Import::importvideoData($docObj['extrafields']['video']['entity']), 'phone' => $this->converttoArray($docObj['est_phone']), 'mobile' => $this->converttoArray($docObj['est_mobile']), 'category' => explode(',', $docObj['extrafields']['est_cat_id']), 'types' => explode(',', $docObj['extrafields']['typesid']), 'crowd' => explode(',', $docObj['extrafields']['crowdids']), 'service' => explode(',', $docObj['extrafields']['servicesid']), 'feature' => explode(',', $docObj['extrafields']['featuresid']), 'cuisines' => explode(',', $docObj['extrafields']['cuisinesid']), 'music' => explode(',', $docObj['extrafields']['musicids']), 'payment' => explode(',', $docObj['extrafields']['paymentids']), 'usp' => explode(',', $docObj['extrafields']['est_usp_id']), 'tag' => $docObj['est_tags']]; return Import::importData($this, $docObj, $mappingVanue, $mappingfunction, $data); }
/** * * @param string $jsonDOC * @return boolean */ public function import($jsonDOC) { //echo $jsonDOC."\n"; Yii::info("Restaurant input:" . $jsonDOC); $docObj = Json::decode($jsonDOC, true); $mappingVanue = ["_id" => "Id", "movie_name" => "name", "cast" => 'cast', "synopsis" => "synopsis", "languageId" => "launguageId", "parentalGuidance" => "parentalGuidance", "editor_rating" => "starRating", "old_editor_rating" => "oldStarRating", "users_rating" => "avgerageUserRate", "review_count" => "reviewCount", "releasedate" => "releaseDate", "status" => "status", "movieshortname" => "alias", "tagline" => "tagline", "review" => "review", "length" => "length", "moviedirector" => "movieDirector", "musicdirector" => "musicDirector", "movie_guid" => "guid", "toi_movie_id" => "toiMovieId", "genres" => false, 'extrafields' => false, 'languageName' => false, 'theaterid' => false, 'movieimage' => false, 'genres_name_ft' => false, 'movie_video_present' => false, 'languageName_ft' => false, 'movie_name_cl' => false, 'parentalGuidance_ft' => false, 'popularity_score' => false, 'rand' => false, 'georand' => false, 'movie_video_code' => false, 'is_showtime' => false, 'state' => 'state']; $mappingfunction = ["releasedate" => function ($data, $row) { return $data['sec'] > 0 ? date('Y-m-d', $data['sec']) : ''; }, "cast" => function ($data, $row) { return is_array($data) ? implode(', ', $data) : $data; }, "state" => function ($date, $row) { switch ((int) $row['status']) { case 1: $ret = AppActiveRecord::STATUS_PUBLISH; break; case 0: $ret = AppActiveRecord::STATUS_DELETE; break; default: $ret = AppActiveRecord::STATUS_UNPUBLISH; break; } return $ret; }]; $data = ['media' => Import::importMediaData($docObj['extrafields']['images']['entity'], $this->imagePath), 'video' => Import::importvideoData($docObj['extrafields']['video']['entity']), 'genres' => explode(',', $docObj['extrafields']['genres'])]; return Import::importData($this, $docObj, $mappingVanue, $mappingfunction, $data); }