PHP - ayuda en codigo PHP

 
Vista:

ayuda en codigo PHP

Publicado por entrepids (1 intervención) el 06/12/2011 23:55:27
hola amigos este es mi codigo lo que quiero hacer es que ne donde tengo la flechas me muestre loos numero de sku que no se actualizaron ya que el contador me muestra cuando son pero no que numero.

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
class Entrepids_Triggers_Model_Trigger_Product_Price extends Entrepids_Triggers_Model_Trigger
{
 
    protected $type = 'technical,operative';
    protected $log = 'product_price.log';
    protected $processName = 'ACTUALIZACION DE PRECIOS';
 
    protected function process()
    {
 
        try {
            $fileName = 'Prices.csv';
 
            $this->log('COMENZANDO LA VERIFICACION DEL ARCHIVO');
            $f = fopen(Mage::getBaseDir('var') . DS . 'import' . DS . $fileName, 'r');
            if ($f === false) {
                $this->log('NO SE ENCUENTRA EL ARCHIVO "'.$fileName.'"');
                return;
            }
 
            $result = array();
 
            while (( $tmp = fgetcsv($f) ) !== false) {
                if (count($tmp) != 2)
                    continue;
                $result[] = array('sku' => $tmp[0], 'price' => $tmp [1]);
            }
 
            fclose($f);
 
            if (($lineas = count($result)) > 0) {
                $this->log('EL TOTAL DE LINEAS ENCONTRADAS FUERON:' . $lineas);
            } else {
                $this->log('EL ARCHIVO SE ENCUENTRA VACIO');
                $this->moveFromImportToCompleted($fileName);
                return;
            }
 
            $this->log('INICIA ACTUALIZACION');
			$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
            $updated = 0;
            $failed = 0;
            foreach ($result as $row) {
            $update = "UPDATE catalog_product_entity_decimal a JOIN catalog_product_entity b ON a.entity_id = b.entity_id
		SET a.value = {$row['price']}
		WHERE b.sku = '{$row['sku']}'
		AND a.entity_type_id = 4
		AND a.attribute_id = 64";
                try {
                    $writeConnection->query($update);
                    $updated++;
                } catch (Exception $e) {
                    $this->log('ERROR: ' . $update);
                    $failed++;
                     continue;
                }
           }
 
            $this->log('TERMINA ACTUALIZACION');
            $this->log('PRODUCTOS ACTUALIZADOS: ' . $updated);      <----- sku fallidos
            $this->log('PRODUCTOS FALLIDOS: ' . $failed);
            //sku
   --------->
             $actualizar="{$row['sku']}";
 
            $this->log('LOS SKU QUE NO SE ACTUALIZARON FUERON:'. $actualizar );
 
               //fin sku   
   ------------>
 
            $this->log('INICIA REINDEXADO');
            $processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
            $processes->walk('reindexAll');
            $this->log('TERMINA REINDEXADO');
        } catch (Exception $e) {
            $this->log('ERROR:' . $e->getTraceAsString());
        }
        $this->moveFromImportToCompleted($fileName);
    }
}

espero me puedan ayudar me urgue gracias :-)
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder