示例#1
0
 function saveCompleteRequestToFile(MultiRequest_Request $request, MultiRequest_Handler $handler)
 {
     $filename = preg_replace('/[^\\w\\.]/', '', $request->getUrl());
     file_put_contents($this->temp_folder . "xml-{$request->dws_id}.xml", $request->getContent());
     $xml = simplexml_load_string($request->getContent());
     $active_cats = array();
     foreach ($xml->row as $row) {
         $data = array();
         $product_group = $this->fixRecord($row->product_group);
         $cat_arr = str_split($product_group, 2);
         $data['stockid'] = $this->fixRecord($row->stockid);
         $data['stock_code'] = $this->fixRecord($row->part);
         $data['product_group'] = $product_group;
         $data['cat_1'] = isset($cat_arr[0]) ? $cat_arr[0] : '';
         $data['cat_2'] = isset($cat_arr[0]) && isset($cat_arr[1]) ? $cat_arr[0] . $cat_arr[1] : '';
         $data['cat_3'] = isset($cat_arr[0]) && isset($cat_arr[1]) && isset($cat_arr[2]) ? $cat_arr[0] . $cat_arr[1] . $cat_arr[2] : '';
         $data['product_name'] = $this->fixRecord($row->desc1);
         $data['product_alias'] = $this->fixRecord($row->part);
         $data['unit_size'] = $this->fixRecord($row->duoi);
         $data['qty_units_per_case'] = $this->fixRecord($row->uoi);
         $data['retail_price'] = $this->fixRecord($row->retail_price);
         $data['por'] = 0;
         $data['cost_price'] = $this->fixRecord($row->cost);
         $data['list_price'] = $this->fixRecord($row->list_price);
         $data['carriage_charge'] = $this->fixRecord($row->carriage_charge);
         $data['collect_price_offer'] = 0;
         $data['delivery_price'] = $this->fixRecord($row->list_price);
         $data['delivery_price_offer'] = 0;
         $data['collect_club_price'] = 0;
         $data['delivery_club_price'] = 0;
         $data['vat_id'] = $this->fixRecord($row->vat);
         $data['qty_hand'] = $this->fixRecord($row->qty_hand);
         $data['qty_aloc'] = $this->fixRecord($row->qty_aloc);
         $data['product_weight'] = $this->fixRecord($row->weight);
         $data['abv_percent'] = $this->fixRecord($row->wines_abv);
         $data['web_image'] = $this->fixRecord($row->web_image);
         $data['flag_offers'] = $this->fixRecord($row->flag_offers);
         $data['product_meta_desc'] = '';
         $data['product_meta_keywords'] = '';
         $data['product_is_active'] = 1;
         $data['product_added_on'] = 1;
         $status = $this->CI->db->insert('product', $data);
         if ($status) {
             $active_cats[] = $data['cat_1'];
             $active_cats[] = $data['cat_2'];
             $active_cats[] = $data['cat_3'];
         }
     }
     $active_cats = array_unique($active_cats);
     foreach ($active_cats as $cat_code) {
         if ($cat_code == '') {
             continue;
         }
         $update = array();
         $update['category_is_active'] = 1;
         $this->CI->db->where('category_code', $cat_code);
         $this->CI->db->update('category', $update);
     }
 }
示例#2
0
function saveCompleteRequestToFile(MultiRequest_Request $request, MultiRequest_Handler $handler)
{
    $filename = preg_replace('/[^\\w\\.]/', '', $request->getUrl());
    file_put_contents(DOWNLOADS_DIR . DIRECTORY_SEPARATOR . $filename, $request->getContent());
}