Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. // We don't care if dealer identifier matches, proceed with 'standard' evaluation
  2. // Export only used! As of this time 05/30/18 Marketplace only supports USED
  3. if(isset($temp_line[$columns_merged['state_of_vehicle']]) && (strtolower($temp_line[$columns_merged['state_of_vehicle']]) !== $this->dealer_identifier_value)) {
  4. //log_message('debug', __FUNCTION__."() -- Used vehicle found.");
  5. // Check for empty prices
  6. if(isset($grab['price']) && (!empty($grab['price']) && $grab['price'] !== "0 {$line_currency}")) {
  7. //log_message('debug', __FUNCTION__."() -- Valid price found.");
  8. // Check for a photo
  9. if(isset($grab['images']) && !empty($grab['images']) && is_array($grab['images']) && count($grab['images']) > 1) {
  10. //log_message('debug', __FUNCTION__."() -- Valid image URL found.");
  11. // Valid Mileage value
  12. if(isset($grab['mileage_value']) && !empty($grab['mileage_value']) && strlen($grab['mileage_value']) > 2 && ($grab['mileage_value'] > 499)) {
  13. //log_message('debug', __FUNCTION__."() -- Valid mileage value found.");
  14. // No empty VDP
  15. //if(isset($grab['url']) && !empty($grab['url']) && strlen($grab['url']) > 1) {
  16. //log_message('debug', __FUNCTION__."() -- Valid URL.");
  17.  
  18. // Does the VDP URL contain the dealership URL?
  19. if(strpos($grab['url'], $this->client_parsed_hostname) !== FALSE) {
  20. //log_message('debug', __FUNCTION__."() Dealer Hostname found...");
  21. $the_data[] = $grab;
  22. $vins_and_urls_list[] = [
  23. 'vin' => $grab['vin'],
  24. 'url' => $grab['url'],
  25. 'neworused' => (isset($grab['state_of_vehicle']) && strtolower($grab['state_of_vehicle']) == strtolower($this->state_of_vehicle_field)) ? 1 : 0
  26. ];
  27. }
  28. //}
  29. }
  30. }
  31. }
  32. }
  33. }
  34. }
  35.  
  36. // Reset the counter!
  37. $column_count = 1;
  38. $plucked_line_data = [];
  39. $grab = [];
  40. }
  41. $column_count++;
  42. }
  43. }
  44. fclose($handle);
  45.  
  46. // dump it
  47. //print_r($plucked_line_data);
  48. $data_count = count($the_data);
  49. log_message('debug', __FUNCTION__."() Successfully generated {$data_count} rows of something...");
  50.  
  51. log_message('debug', __FUNCTION__."() Loading parser...");
  52. $xml_data = [
  53. 'feed_name' => '', // TODO Set to dealer name? scope line_dealer_name ??,
  54. 'link' => '', // TODO set to dealer URL? same as above.
  55. 'listings' => $the_data,
  56. ];
  57.  
  58. $this->CI->load->library('parser');
  59. $xml_markup = $this->CI->parser->parse('templates/marketplace', $xml_data, TRUE);
  60.  
  61. // Next build the catalog (precursor to VDP evaluation, this originates VINs and URLs and assumes we need to redirect)
  62. $this->CI->load->model('Catalog_model', 'catalog_model');
  63. $job_datetime = date('ymdHi');
  64. $item_datetime = date('Y-m-d H:i:s');
  65.  
  66. $catalog_data = [];
  67. foreach($vins_and_urls_list as $vin_item) {
  68. // Check if we've got valid values for VIN and URL to add to the pile
  69. //if((isset($vin_item['vin']) && !empty($vin_item)) && (isset($vin_item['url']) && !empty($vin_item['url']))) {
  70. if(!empty($vin_item) && isset($vin_item['vin'])) {
  71. $catalog_data[] = [
  72. 'client_id' => $client_id,
  73. 'job_number' => $job_datetime,
  74. 'vin' => $vin_item['vin'],
  75. 'initial_url' => $vin_item['url'],
  76. 'created_at' => $item_datetime,
  77. 'updated_at' => $item_datetime,
  78. 'neworused' => $vin_item['neworused']
  79. ];
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement