toevoeging script

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Endy voest

endy voest

04/09/2012 18:23:41
Quote Anchor link
Ik zit met een (voor mij) lastig te tackelen probleempje.

Het betreft een prestashop omgeving, waarvoor ik een custom database value export to .cvs module heb aangeschaft.
Deze module werkt overigens prima, echter wil ik een stukje code aan het script toevoegen waardoor er extra waardes in het te exporteren .csv bestand kunnen worden toegevoegd.

Dit zijn waardes betreffende de diverse bestellingen door klanten.
Hieronder zie je een snapshot van de tabel die ik wil benaderen middels het stukje code wat je kunt vinden bij:(scroll naar beneden) //TO GET CUSTOMIZED_DATA VALUES FROM DATABASE 04-09-2012

Afbeelding

Wat ik uiteindelijk in het .csv bestand krijg is op elke regel "Array" in plaats van een waarde.

Zie voorbeeld:
Afbeelding

Wat doe ik verkeerd?
Het gaat om dit stukje door mij toegevoegde code $print_name = Db::getInstance()->getRow('SELECT `id_cus...........

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php

$address_choice
= $_POST['address_choice'];

// natuurlijk details van de orders
$orders_detail = Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'order_detail` od
                                            LEFT JOIN `'
._DB_PREFIX_.'orders` o ON (o.`id_order` = od.`id_order`)
                                            WHERE `date_add` >= "'
.$date_start.'"
                                            AND `date_add` <= "'
.$date_end.'"');
foreach($orders_detail as $order_detail){
    if(Customer::customerIdExists($order_detail['id_customer'])){
        $f_no = array();
        // Objet commande
        $Order = new Order($order_detail['id_order']);
        $order = $Order->getFields();

        $f_no[1] = $order_detail['id_order'];
        $f_no[2] = $order_detail['id_order_detail'];
        $f_no[3] = date("d.m.Y", strtotime($order['date_add']));
            // info client
            $Customer = new Customer($order['id_customer']);
            $customer = $Customer->getFields();
            if($customer['id_gender']==1){$gender=$this->l('Monsieur');}else{$gender=$this->l('Madame');}
            // info adresse
            if($address_choice=='delivery'){
                $Address = new Address($order['id_address_delivery']);
            }
else{
                $Address = new Address($order['id_address_invoice']);
            }

            $address = $Address->getFields();
        $f_no[38] = $address['company'];
        $f_no[4] = $gender;
        $f_no[5] = $customer['firstname'];
        $f_no[6] = $customer['lastname'];
        $f_no[7] = $address['address1'];
        $f_no[8] = $address['address2'];
        $f_no[9] = $address['postcode'];
        $f_no[10] = $address['city'];
            $country = Country::getNameById($order['id_lang'],$address['id_country']);
        $f_no[11] = $country;
        $f_no[12] = $address['phone'];
        $f_no[13] = $address['phone_mobile'];
        $f_no[14] = $customer['email'];
        $f_no[15] = $customer['birthday'];
            if($customer['newsletter']){
                $newsletter=$this->l('Oui');
            }
else{
                $newsletter = $this->l('Non');
            }

        $f_no[16] = $newsletter;
            $group = '';
            // v1.3 +
            if(isset($customer['id_default_group'])){
                $Group = new Group($customer['id_default_group']);
                $group = $Group->name[$order['id_lang']];
            }
else{
                $res = Db::getInstance()->getRow('SELECT `id_group` FROM '._DB_PREFIX_.'customer_group WHERE `id_customer` = "'.$order_detail['id_customer'].'"');
                $Group = new Group($res['id_group']);
                $group = $Group->name[$order['id_lang']];
            }

        $f_no[17] = $group;
        $f_no[18] = $order_detail['product_quantity'];
        $f_no[19] = $order_detail['product_name'];
        $f_no[20] = round($order_detail['product_price']+($order_detail['product_price']*$order_detail['tax_rate']/100),2);
        $f_no[21] = $order_detail['tax_rate'];
        $f_no[22] = $order_detail['product_weight'];
        $f_no[23] = $order_detail['product_ean13'];
        $f_no[24] = $order_detail['product_reference'];
        $f_no[25] = $order_detail['product_supplier_reference'];
        $f_no[26] = $order['total_paid'];
        $f_no[27] = $order['total_paid_real'];
        $f_no[28] = $order['total_shipping'];
           $Currency = new Currency($order['id_currency']);
           $currency = $Currency->getFields();
        $f_no[29] = $currency['iso_code'];
        $f_no[30] = $order['payment'];
        $f_no[31] = $order['invoice_number'];
        $f_no[32] = $order['delivery_number'];
            if($order['id_carrier']>0){
                $Carrier = new Carrier($order['id_carrier']);
                $carrier = $Carrier->getFields();
                $carrier_name = $carrier['name'];
            }
else{
                $carrier_name = '';
            }

        $f_no[33] = $carrier_name;
            $Language = new Language($order['id_lang']);
            $language = $Language->getFields();
        $f_no[34] = $language['name'];
        $f_no[35] = $order['invoice_date'];

        // récupère l'emplacement du produit
        $id_product = $order_detail['product_id'];
        // simple
        if(empty($order_detail['product_attribute_id'])){
            $product = Db::getInstance()->getRow('SELECT `location`,`wholesale_price` FROM '._DB_PREFIX_.'product WHERE `id_product`="'.$id_product.'"');
            $location = $product['location'];
            $wholesale_price = $product['wholesale_price'];
        // déclinaison
        }else{
            $id_product_attribute = $order_detail['product_attribute_id'];
            $productDecl = Db::getInstance()->getRow('SELECT `location`,`wholesale_price` FROM '._DB_PREFIX_.'product_attribute WHERE `id_product`="'.$id_product.'" AND `id_product_attribute`="'.$id_product_attribute.'"');
            $location = $productDecl['location'];
            $wholesale_price = $productDecl['wholesale_price'];
        }

        $f_no[36] = $location;
        $f_no[37] = $wholesale_price;
//TO GET CUSTOMIZED_DATA VALUES FROM DATABASE 04-09-2012
$print_name = Db::getInstance()->getRow('SELECT `id_customization` FROM '._DB_PREFIX_.'customized_data');
$f_no[39] = $print_name;

        // Ordonne les cellules selon la base de donnée
        $f_place = array();
        if(is_array($fields_no)){
            foreach($fields_no as $field_no){
               $res = Db::getInstance()->ExecuteS('SELECT `place` FROM '._DB_PREFIX_.'customexporter WHERE `field_no`='.$field_no.' AND `export_type`="'.$export_type.'"');
               $place = $res[0]['place'];
               $f_place[$place] = $f_no[$field_no];
            }
        }

        $this->file[] = $f_place; // ajoute nouvelle ligne triée au fichier
    } // end if customer exist
}
?>
Gewijzigd op 04/09/2012 18:25:15 door Endy voest
 
PHP hulp

PHP hulp

28/11/2024 08:21:54
 
Ger van Steenderen
Tutorial mod

Ger van Steenderen

04/09/2012 19:15:44
Quote Anchor link
Ooit weleens gedacht aan SELECT ... INTO OUTFILE
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.