Cannot add new products or they get mixed up with updated ones, no errorGet soled Products with counter in MagentoCreate invoice and shipment in magento via cron based on store view and order ageExclude a specific categoryCreate categories through installerSet Products Out Of Stock If They Haven't Been Updated Within A DayAdd new Attributes with Add more buttonadd to cart products with max qty of products error with run scriptSQL Error When Making New Products on Magento “Column 'price_type' cannot be null”Magento 1.9 - Get new productsExport Category name in xml feed Magento 1.9.2

I got the following comment from a reputed math journal. What does it mean?

What is the term when voters “dishonestly” choose something that they do not want to choose?

Why is there so much iron?

Turning a hard to access nut?

Do I need to consider instance restrictions when showing a language is in P?

Can other pieces capture a threatening piece and prevent a checkmate?

Is there a creature that is resistant or immune to non-magical damage other than bludgeoning, slashing, and piercing?

Should I be concerned about student access to a test bank?

I seem to dance, I am not a dancer. Who am I?

Does the attack bonus from a Masterwork weapon stack with the attack bonus from Masterwork ammunition?

Do I need to be arrogant to get ahead?

What does "Four-F." mean?

Relation between independence and correlation of uniform random variables

Variable completely messes up echoed string

PTIJ: Do Irish Jews have "the luck of the Irish"?

Help rendering a complicated sum/product formula

Practical application of matrices and determinants

Deletion of copy-ctor & copy-assignment - public, private or protected?

Print a physical multiplication table

Probably overheated black color SMD pads

What favor did Moody owe Dumbledore?

Recruiter wants very extensive technical details about all of my previous work

Are dual Irish/British citizens bound by the 90/180 day rule when travelling in the EU after Brexit?

Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?



Cannot add new products or they get mixed up with updated ones, no error


Get soled Products with counter in MagentoCreate invoice and shipment in magento via cron based on store view and order ageExclude a specific categoryCreate categories through installerSet Products Out Of Stock If They Haven't Been Updated Within A DayAdd new Attributes with Add more buttonadd to cart products with max qty of products error with run scriptSQL Error When Making New Products on Magento “Column 'price_type' cannot be null”Magento 1.9 - Get new productsExport Category name in xml feed Magento 1.9.2













0















I have written a simple script that downloads an XML with product info from a wholesale parse it and save new products or updates exiting ones. It has been working for a few months, but now it's getting really strange. It updates existing products correctly, but it doesn't add a new ones (no error at all) or it overwrites an existing product with the new ones data. I've been trying to find any clue, to debug I output almost any valuable info, but it just won't work.



This is my script:



<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
require_once('Kategorie.php');
$kat = new Kategorie();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$product = Mage::getModel('catalog/product');

$xml=simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getdb&id=XX&p=XX") or die("Error: Cannot create object ksiazki");
//$xml=simplexml_load_file("testdb.xml");

$ksiazki = array();
$dostepnosc = array();
$ceny = array();

echo count($xml->books->book)." książek pobrano.<br>";

if (count($xml->books->book) > 0)

foreach ($xml->books->book as $book)

if ($book->attributes()->dzial == "KC")

if ($kat->isIndexHistoric((string)$book->attributes()->indeks))

array_push($ksiazki, $book);

//pobieranie obrazow
$url = "http://services.azymut.pl/oferta/servlet/?mode=getImg&indeks=".$book->attributes()->indeks."&id=XX&p=XX";
$path = dirname(__FILE__)."/media/books/".$book->attributes()->indeks.".jpeg";
$urlFile = "/media/books/".$book->attributes()->indeks.".jpeg";
try

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$img = curl_exec($curl);
curl_close($curl);
$data = imagecreatefromstring($img);
if (isset($data))

imagejpeg($data,$path);


catch(Exception $e)

echo "MagentoError: ".$e->getMessage();
Mage::log($e->getMessage());


echo $book->attributes()->indeks.": ".(file_exists($path) ? "Pobrano obrazek.(/media/books/".$book->attributes()->indeks.".jpeg)<br>" : "Brak obrazka w bazie Azymuta.<br>");




$transakcja = $xml->attributes()->transactionId;
echo "Transakcja ".$xml->attributes()->transactionId."<br>";

$xml2 = simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getAvail&id=XX&p=XX") or die("Error: Cannot create object dostepnosc");

foreach ($xml2->book as $book)

$index = (string)$book->attributes()->indeks;
$dostepnosc[$index] = intval($book->attributes()->p);


echo "Pobrano ".count($dostepnosc)." dostepnosci.<br>";

$xml2 = simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getPrice&id=XX&p=XX") or die("Error: Cannot create object ceny");

foreach ($xml2->book as $book)

$index = (string)$book->attributes()->indeks;
$ceny[$index] = $book->attributes()->cena;
$ceny[$index] = 1.30 * $ceny[$index]; //marza 30%
$ceny[$index] = 1.05 * $ceny[$index]; //vat 5%
$ceny[$index] = round($ceny[$index], 1);


echo "Pobrano ".count($ceny)." cen.<br>";

for ($i = 0;$i < count($ksiazki);$i++)



if ($i == count($ksiazki) - 1 || count($xml->books->book) == 0 || count($ksiazki == 0))

//file_get_contents("http://services.azymut.pl/oferta/servlet/?mode=confirm&id=XX&p=XX&transactionId=".$transakcja) or die("Error: Cannot create object confirmation");
echo "Koniec transakcji.<br>";



?>



Why Am I deleting the products at the beginning? It was just one of my blind shots, I wanted to start fresh, but the result was: none of the 500 products has been saved.



And here is the example of the output:



<code>
500 książek pobrano.
37100801579KS: Pobrano obrazek.(/media/books/37100801579KS.jpeg)
41595401615KS: Brak obrazka w bazie Azymuta.
41976601579KS: Pobrano obrazek.(/media/books/41976601579KS.jpeg)
42172001579KS: Pobrano obrazek.(/media/books/42172001579KS.jpeg)
43471102044KS: Brak obrazka w bazie Azymuta.
47354301615KS: Pobrano obrazek.(/media/books/47354301615KS.jpeg)
47359102056KS: Pobrano obrazek.(/media/books/47359102056KS.jpeg)
47495801965KS: Pobrano obrazek.(/media/books/47495801965KS.jpeg)
48445501615KS: Brak obrazka w bazie Azymuta.
49282501184KS: Brak obrazka w bazie Azymuta.
49596001579KS: Pobrano obrazek.(/media/books/49596001579KS.jpeg)
49686001350KS: Pobrano obrazek.(/media/books/49686001350KS.jpeg)
49974001615KS: Pobrano obrazek.(/media/books/49974001615KS.jpeg)
50090000207KS: Pobrano obrazek.(/media/books/50090000207KS.jpeg)
50256601579KS: Pobrano obrazek.(/media/books/50256601579KS.jpeg)
52775100231KS: Pobrano obrazek.(/media/books/52775100231KS.jpeg)
53308401041KS: Pobrano obrazek.(/media/books/53308401041KS.jpeg)
53650002269KS: Brak obrazka w bazie Azymuta.
54326401144KS: Pobrano obrazek.(/media/books/54326401144KS.jpeg)
55247402249KS: Brak obrazka w bazie Azymuta.
55250302062KS: Brak obrazka w bazie Azymuta.
57158801622KS: Pobrano obrazek.(/media/books/57158801622KS.jpeg)
57575602706KS: Pobrano obrazek.(/media/books/57575602706KS.jpeg)
58264602706KS: Pobrano obrazek.(/media/books/58264602706KS.jpeg)
60139002894KS: Pobrano obrazek.(/media/books/60139002894KS.jpeg)
60143302894KS: Pobrano obrazek.(/media/books/60143302894KS.jpeg)
60159902894KS: Pobrano obrazek.(/media/books/60159902894KS.jpeg)
60160802894KS: Pobrano obrazek.(/media/books/60160802894KS.jpeg)
60161202894KS: Brak obrazka w bazie Azymuta.
61274601830KS: Brak obrazka w bazie Azymuta.
61829501075KS: Brak obrazka w bazie Azymuta.
61977702706KS: Brak obrazka w bazie Azymuta.
62104401430KS: Pobrano obrazek.(/media/books/62104401430KS.jpeg)
63614801262KS: Brak obrazka w bazie Azymuta.
64253303114KS: Brak obrazka w bazie Azymuta.
64894500149KS: Brak obrazka w bazie Azymuta.
65196601622KS: Brak obrazka w bazie Azymuta.
65392002743KS: Brak obrazka w bazie Azymuta.
66167802894KS: Brak obrazka w bazie Azymuta.
66338102894KS: Brak obrazka w bazie Azymuta.
66690002894KS: Brak obrazka w bazie Azymuta.
66988102894KS: Brak obrazka w bazie Azymuta.
67454302494KS: Brak obrazka w bazie Azymuta.
67848500153KS: Pobrano obrazek.(/media/books/67848500153KS.jpeg)
68804402044KS: Pobrano obrazek.(/media/books/68804402044KS.jpeg)
70217100206KS: Brak obrazka w bazie Azymuta.
70217400206KS: Brak obrazka w bazie Azymuta.
70227603326KS: Pobrano obrazek.(/media/books/70227603326KS.jpeg)
70341400124KS: Pobrano obrazek.(/media/books/70341400124KS.jpeg)
70360802389KS: Pobrano obrazek.(/media/books/70360802389KS.jpeg)
70362502608KS: Pobrano obrazek.(/media/books/70362502608KS.jpeg)
70486401049KS: Pobrano obrazek.(/media/books/70486401049KS.jpeg)
70491003053KS: Pobrano obrazek.(/media/books/70491003053KS.jpeg)
70491203053KS: Brak obrazka w bazie Azymuta.
70526003143KS: Pobrano obrazek.(/media/books/70526003143KS.jpeg)
70526701252KS: Brak obrazka w bazie Azymuta.
70530302894KS: Brak obrazka w bazie Azymuta.
70550401646KS: Brak obrazka w bazie Azymuta.
70551601405KS: Brak obrazka w bazie Azymuta.
70557401144KS: Brak obrazka w bazie Azymuta.
70559601648KS: Pobrano obrazek.(/media/books/70559601648KS.jpeg)
70649402608KS: Brak obrazka w bazie Azymuta.
70658902608KS: Brak obrazka w bazie Azymuta.
70662201184KS: Brak obrazka w bazie Azymuta.
70682202798KS: Brak obrazka w bazie Azymuta.
70685101549KS: Brak obrazka w bazie Azymuta.
70689500208KS: Pobrano obrazek.(/media/books/70689500208KS.jpeg)
70693701252KS: Brak obrazka w bazie Azymuta.
70695103053KS: Brak obrazka w bazie Azymuta.
70719900208KS: Pobrano obrazek.(/media/books/70719900208KS.jpeg)
70720100208KS: Brak obrazka w bazie Azymuta.
70720200208KS: Pobrano obrazek.(/media/books/70720200208KS.jpeg)
70720400208KS: Pobrano obrazek.(/media/books/70720400208KS.jpeg)
70740003022KS: Pobrano obrazek.(/media/books/70740003022KS.jpeg)
70744600203KS: Pobrano obrazek.(/media/books/70744600203KS.jpeg)
70753403053KS: Pobrano obrazek.(/media/books/70753403053KS.jpeg)
70755102370KS: Pobrano obrazek.(/media/books/70755102370KS.jpeg)
70755302370KS: Pobrano obrazek.(/media/books/70755302370KS.jpeg)
70761603133KS: Brak obrazka w bazie Azymuta.
Transakcja 11145-1424312459597
Pobrano 107534 dostepnosci.
Pobrano 134930 cen.
Usuniecie 4243ID:
37100801579KS
ID:29376
37100801579KS
Tytuł: MW
ISBN: 839176124X
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
2 kategorii do przypisania.
2Kategorii zapisano.
Zapisano 37100801579KS .
37100801579KS
MW
Koniec produktu.
Usuniecie 4906ID:
41595401615KS
ID:29376
41595401615KS
Tytuł: Historia polityczna świata XX w t1 1901-1945
ISBN: 8323318522
Debug: Path - FALSE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
MagentoError: Image does not exist.7 kategorii do przypisania.
7Kategorii zapisano.
Zapisano 41595401615KS .
41595401615KS
Historia polityczna świata XX w t1 1901-1945
Koniec produktu.
Usuniecie 4974ID:
41976601579KS
ID:29376
41976601579KS
Tytuł: Salon 2. Alfabet szulerów. Część pierwsza A-L
ISBN: 8360297118
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
3 kategorii do przypisania.
3Kategorii zapisano.
Zapisano 41976601579KS .
41976601579KS
Salon 2. Alfabet szulerów. Część pierwsza A-L
Koniec produktu.
Usuniecie 2240ID:
42172001579KS
ID:29376
42172001579KS
Tytuł: Salon 2 Alfabet szulerów
ISBN: 8360297126
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
3 kategorii do przypisania.
3Kategorii zapisano.
Zapisano 42172001579KS .
42172001579KS
Salon 2 Alfabet szulerów
Koniec produktu.
Usuniecie 5376ID:
43471102044KS
ID:29376
43471102044KS
Tytuł: Tajemnica Las Meninas
ISBN: 9788389368737
Debug: Path - FALSE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
MagentoError: Image does not exist.2 kategorii do przypisania.
2Kategorii zapisano.
Zapisano 43471102044KS .
43471102044KS
Tajemnica Las Meninas
Koniec produktu.
Koniec transakcji.
</code>









share|improve this question
























  • Do you have a store with id 4 in your site?

    – Girish SH
    Feb 19 '15 at 2:55











  • Yes, but it doesn't work on any ID and even if I comment this line. Note one weird fact: every "saved" object in this example output has exactly the same ID. I dont know why. It's this line for example: 41976601579KS ID:29376 <- this is the ID of every product and it's the same! 41976601579KS

    – Richard Rahl
    Feb 19 '15 at 3:08
















0















I have written a simple script that downloads an XML with product info from a wholesale parse it and save new products or updates exiting ones. It has been working for a few months, but now it's getting really strange. It updates existing products correctly, but it doesn't add a new ones (no error at all) or it overwrites an existing product with the new ones data. I've been trying to find any clue, to debug I output almost any valuable info, but it just won't work.



This is my script:



<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
require_once('Kategorie.php');
$kat = new Kategorie();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$product = Mage::getModel('catalog/product');

$xml=simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getdb&id=XX&p=XX") or die("Error: Cannot create object ksiazki");
//$xml=simplexml_load_file("testdb.xml");

$ksiazki = array();
$dostepnosc = array();
$ceny = array();

echo count($xml->books->book)." książek pobrano.<br>";

if (count($xml->books->book) > 0)

foreach ($xml->books->book as $book)

if ($book->attributes()->dzial == "KC")

if ($kat->isIndexHistoric((string)$book->attributes()->indeks))

array_push($ksiazki, $book);

//pobieranie obrazow
$url = "http://services.azymut.pl/oferta/servlet/?mode=getImg&indeks=".$book->attributes()->indeks."&id=XX&p=XX";
$path = dirname(__FILE__)."/media/books/".$book->attributes()->indeks.".jpeg";
$urlFile = "/media/books/".$book->attributes()->indeks.".jpeg";
try

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$img = curl_exec($curl);
curl_close($curl);
$data = imagecreatefromstring($img);
if (isset($data))

imagejpeg($data,$path);


catch(Exception $e)

echo "MagentoError: ".$e->getMessage();
Mage::log($e->getMessage());


echo $book->attributes()->indeks.": ".(file_exists($path) ? "Pobrano obrazek.(/media/books/".$book->attributes()->indeks.".jpeg)<br>" : "Brak obrazka w bazie Azymuta.<br>");




$transakcja = $xml->attributes()->transactionId;
echo "Transakcja ".$xml->attributes()->transactionId."<br>";

$xml2 = simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getAvail&id=XX&p=XX") or die("Error: Cannot create object dostepnosc");

foreach ($xml2->book as $book)

$index = (string)$book->attributes()->indeks;
$dostepnosc[$index] = intval($book->attributes()->p);


echo "Pobrano ".count($dostepnosc)." dostepnosci.<br>";

$xml2 = simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getPrice&id=XX&p=XX") or die("Error: Cannot create object ceny");

foreach ($xml2->book as $book)

$index = (string)$book->attributes()->indeks;
$ceny[$index] = $book->attributes()->cena;
$ceny[$index] = 1.30 * $ceny[$index]; //marza 30%
$ceny[$index] = 1.05 * $ceny[$index]; //vat 5%
$ceny[$index] = round($ceny[$index], 1);


echo "Pobrano ".count($ceny)." cen.<br>";

for ($i = 0;$i < count($ksiazki);$i++)



if ($i == count($ksiazki) - 1 || count($xml->books->book) == 0 || count($ksiazki == 0))

//file_get_contents("http://services.azymut.pl/oferta/servlet/?mode=confirm&id=XX&p=XX&transactionId=".$transakcja) or die("Error: Cannot create object confirmation");
echo "Koniec transakcji.<br>";



?>



Why Am I deleting the products at the beginning? It was just one of my blind shots, I wanted to start fresh, but the result was: none of the 500 products has been saved.



And here is the example of the output:



<code>
500 książek pobrano.
37100801579KS: Pobrano obrazek.(/media/books/37100801579KS.jpeg)
41595401615KS: Brak obrazka w bazie Azymuta.
41976601579KS: Pobrano obrazek.(/media/books/41976601579KS.jpeg)
42172001579KS: Pobrano obrazek.(/media/books/42172001579KS.jpeg)
43471102044KS: Brak obrazka w bazie Azymuta.
47354301615KS: Pobrano obrazek.(/media/books/47354301615KS.jpeg)
47359102056KS: Pobrano obrazek.(/media/books/47359102056KS.jpeg)
47495801965KS: Pobrano obrazek.(/media/books/47495801965KS.jpeg)
48445501615KS: Brak obrazka w bazie Azymuta.
49282501184KS: Brak obrazka w bazie Azymuta.
49596001579KS: Pobrano obrazek.(/media/books/49596001579KS.jpeg)
49686001350KS: Pobrano obrazek.(/media/books/49686001350KS.jpeg)
49974001615KS: Pobrano obrazek.(/media/books/49974001615KS.jpeg)
50090000207KS: Pobrano obrazek.(/media/books/50090000207KS.jpeg)
50256601579KS: Pobrano obrazek.(/media/books/50256601579KS.jpeg)
52775100231KS: Pobrano obrazek.(/media/books/52775100231KS.jpeg)
53308401041KS: Pobrano obrazek.(/media/books/53308401041KS.jpeg)
53650002269KS: Brak obrazka w bazie Azymuta.
54326401144KS: Pobrano obrazek.(/media/books/54326401144KS.jpeg)
55247402249KS: Brak obrazka w bazie Azymuta.
55250302062KS: Brak obrazka w bazie Azymuta.
57158801622KS: Pobrano obrazek.(/media/books/57158801622KS.jpeg)
57575602706KS: Pobrano obrazek.(/media/books/57575602706KS.jpeg)
58264602706KS: Pobrano obrazek.(/media/books/58264602706KS.jpeg)
60139002894KS: Pobrano obrazek.(/media/books/60139002894KS.jpeg)
60143302894KS: Pobrano obrazek.(/media/books/60143302894KS.jpeg)
60159902894KS: Pobrano obrazek.(/media/books/60159902894KS.jpeg)
60160802894KS: Pobrano obrazek.(/media/books/60160802894KS.jpeg)
60161202894KS: Brak obrazka w bazie Azymuta.
61274601830KS: Brak obrazka w bazie Azymuta.
61829501075KS: Brak obrazka w bazie Azymuta.
61977702706KS: Brak obrazka w bazie Azymuta.
62104401430KS: Pobrano obrazek.(/media/books/62104401430KS.jpeg)
63614801262KS: Brak obrazka w bazie Azymuta.
64253303114KS: Brak obrazka w bazie Azymuta.
64894500149KS: Brak obrazka w bazie Azymuta.
65196601622KS: Brak obrazka w bazie Azymuta.
65392002743KS: Brak obrazka w bazie Azymuta.
66167802894KS: Brak obrazka w bazie Azymuta.
66338102894KS: Brak obrazka w bazie Azymuta.
66690002894KS: Brak obrazka w bazie Azymuta.
66988102894KS: Brak obrazka w bazie Azymuta.
67454302494KS: Brak obrazka w bazie Azymuta.
67848500153KS: Pobrano obrazek.(/media/books/67848500153KS.jpeg)
68804402044KS: Pobrano obrazek.(/media/books/68804402044KS.jpeg)
70217100206KS: Brak obrazka w bazie Azymuta.
70217400206KS: Brak obrazka w bazie Azymuta.
70227603326KS: Pobrano obrazek.(/media/books/70227603326KS.jpeg)
70341400124KS: Pobrano obrazek.(/media/books/70341400124KS.jpeg)
70360802389KS: Pobrano obrazek.(/media/books/70360802389KS.jpeg)
70362502608KS: Pobrano obrazek.(/media/books/70362502608KS.jpeg)
70486401049KS: Pobrano obrazek.(/media/books/70486401049KS.jpeg)
70491003053KS: Pobrano obrazek.(/media/books/70491003053KS.jpeg)
70491203053KS: Brak obrazka w bazie Azymuta.
70526003143KS: Pobrano obrazek.(/media/books/70526003143KS.jpeg)
70526701252KS: Brak obrazka w bazie Azymuta.
70530302894KS: Brak obrazka w bazie Azymuta.
70550401646KS: Brak obrazka w bazie Azymuta.
70551601405KS: Brak obrazka w bazie Azymuta.
70557401144KS: Brak obrazka w bazie Azymuta.
70559601648KS: Pobrano obrazek.(/media/books/70559601648KS.jpeg)
70649402608KS: Brak obrazka w bazie Azymuta.
70658902608KS: Brak obrazka w bazie Azymuta.
70662201184KS: Brak obrazka w bazie Azymuta.
70682202798KS: Brak obrazka w bazie Azymuta.
70685101549KS: Brak obrazka w bazie Azymuta.
70689500208KS: Pobrano obrazek.(/media/books/70689500208KS.jpeg)
70693701252KS: Brak obrazka w bazie Azymuta.
70695103053KS: Brak obrazka w bazie Azymuta.
70719900208KS: Pobrano obrazek.(/media/books/70719900208KS.jpeg)
70720100208KS: Brak obrazka w bazie Azymuta.
70720200208KS: Pobrano obrazek.(/media/books/70720200208KS.jpeg)
70720400208KS: Pobrano obrazek.(/media/books/70720400208KS.jpeg)
70740003022KS: Pobrano obrazek.(/media/books/70740003022KS.jpeg)
70744600203KS: Pobrano obrazek.(/media/books/70744600203KS.jpeg)
70753403053KS: Pobrano obrazek.(/media/books/70753403053KS.jpeg)
70755102370KS: Pobrano obrazek.(/media/books/70755102370KS.jpeg)
70755302370KS: Pobrano obrazek.(/media/books/70755302370KS.jpeg)
70761603133KS: Brak obrazka w bazie Azymuta.
Transakcja 11145-1424312459597
Pobrano 107534 dostepnosci.
Pobrano 134930 cen.
Usuniecie 4243ID:
37100801579KS
ID:29376
37100801579KS
Tytuł: MW
ISBN: 839176124X
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
2 kategorii do przypisania.
2Kategorii zapisano.
Zapisano 37100801579KS .
37100801579KS
MW
Koniec produktu.
Usuniecie 4906ID:
41595401615KS
ID:29376
41595401615KS
Tytuł: Historia polityczna świata XX w t1 1901-1945
ISBN: 8323318522
Debug: Path - FALSE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
MagentoError: Image does not exist.7 kategorii do przypisania.
7Kategorii zapisano.
Zapisano 41595401615KS .
41595401615KS
Historia polityczna świata XX w t1 1901-1945
Koniec produktu.
Usuniecie 4974ID:
41976601579KS
ID:29376
41976601579KS
Tytuł: Salon 2. Alfabet szulerów. Część pierwsza A-L
ISBN: 8360297118
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
3 kategorii do przypisania.
3Kategorii zapisano.
Zapisano 41976601579KS .
41976601579KS
Salon 2. Alfabet szulerów. Część pierwsza A-L
Koniec produktu.
Usuniecie 2240ID:
42172001579KS
ID:29376
42172001579KS
Tytuł: Salon 2 Alfabet szulerów
ISBN: 8360297126
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
3 kategorii do przypisania.
3Kategorii zapisano.
Zapisano 42172001579KS .
42172001579KS
Salon 2 Alfabet szulerów
Koniec produktu.
Usuniecie 5376ID:
43471102044KS
ID:29376
43471102044KS
Tytuł: Tajemnica Las Meninas
ISBN: 9788389368737
Debug: Path - FALSE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
MagentoError: Image does not exist.2 kategorii do przypisania.
2Kategorii zapisano.
Zapisano 43471102044KS .
43471102044KS
Tajemnica Las Meninas
Koniec produktu.
Koniec transakcji.
</code>









share|improve this question
























  • Do you have a store with id 4 in your site?

    – Girish SH
    Feb 19 '15 at 2:55











  • Yes, but it doesn't work on any ID and even if I comment this line. Note one weird fact: every "saved" object in this example output has exactly the same ID. I dont know why. It's this line for example: 41976601579KS ID:29376 <- this is the ID of every product and it's the same! 41976601579KS

    – Richard Rahl
    Feb 19 '15 at 3:08














0












0








0








I have written a simple script that downloads an XML with product info from a wholesale parse it and save new products or updates exiting ones. It has been working for a few months, but now it's getting really strange. It updates existing products correctly, but it doesn't add a new ones (no error at all) or it overwrites an existing product with the new ones data. I've been trying to find any clue, to debug I output almost any valuable info, but it just won't work.



This is my script:



<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
require_once('Kategorie.php');
$kat = new Kategorie();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$product = Mage::getModel('catalog/product');

$xml=simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getdb&id=XX&p=XX") or die("Error: Cannot create object ksiazki");
//$xml=simplexml_load_file("testdb.xml");

$ksiazki = array();
$dostepnosc = array();
$ceny = array();

echo count($xml->books->book)." książek pobrano.<br>";

if (count($xml->books->book) > 0)

foreach ($xml->books->book as $book)

if ($book->attributes()->dzial == "KC")

if ($kat->isIndexHistoric((string)$book->attributes()->indeks))

array_push($ksiazki, $book);

//pobieranie obrazow
$url = "http://services.azymut.pl/oferta/servlet/?mode=getImg&indeks=".$book->attributes()->indeks."&id=XX&p=XX";
$path = dirname(__FILE__)."/media/books/".$book->attributes()->indeks.".jpeg";
$urlFile = "/media/books/".$book->attributes()->indeks.".jpeg";
try

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$img = curl_exec($curl);
curl_close($curl);
$data = imagecreatefromstring($img);
if (isset($data))

imagejpeg($data,$path);


catch(Exception $e)

echo "MagentoError: ".$e->getMessage();
Mage::log($e->getMessage());


echo $book->attributes()->indeks.": ".(file_exists($path) ? "Pobrano obrazek.(/media/books/".$book->attributes()->indeks.".jpeg)<br>" : "Brak obrazka w bazie Azymuta.<br>");




$transakcja = $xml->attributes()->transactionId;
echo "Transakcja ".$xml->attributes()->transactionId."<br>";

$xml2 = simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getAvail&id=XX&p=XX") or die("Error: Cannot create object dostepnosc");

foreach ($xml2->book as $book)

$index = (string)$book->attributes()->indeks;
$dostepnosc[$index] = intval($book->attributes()->p);


echo "Pobrano ".count($dostepnosc)." dostepnosci.<br>";

$xml2 = simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getPrice&id=XX&p=XX") or die("Error: Cannot create object ceny");

foreach ($xml2->book as $book)

$index = (string)$book->attributes()->indeks;
$ceny[$index] = $book->attributes()->cena;
$ceny[$index] = 1.30 * $ceny[$index]; //marza 30%
$ceny[$index] = 1.05 * $ceny[$index]; //vat 5%
$ceny[$index] = round($ceny[$index], 1);


echo "Pobrano ".count($ceny)." cen.<br>";

for ($i = 0;$i < count($ksiazki);$i++)



if ($i == count($ksiazki) - 1 || count($xml->books->book) == 0 || count($ksiazki == 0))

//file_get_contents("http://services.azymut.pl/oferta/servlet/?mode=confirm&id=XX&p=XX&transactionId=".$transakcja) or die("Error: Cannot create object confirmation");
echo "Koniec transakcji.<br>";



?>



Why Am I deleting the products at the beginning? It was just one of my blind shots, I wanted to start fresh, but the result was: none of the 500 products has been saved.



And here is the example of the output:



<code>
500 książek pobrano.
37100801579KS: Pobrano obrazek.(/media/books/37100801579KS.jpeg)
41595401615KS: Brak obrazka w bazie Azymuta.
41976601579KS: Pobrano obrazek.(/media/books/41976601579KS.jpeg)
42172001579KS: Pobrano obrazek.(/media/books/42172001579KS.jpeg)
43471102044KS: Brak obrazka w bazie Azymuta.
47354301615KS: Pobrano obrazek.(/media/books/47354301615KS.jpeg)
47359102056KS: Pobrano obrazek.(/media/books/47359102056KS.jpeg)
47495801965KS: Pobrano obrazek.(/media/books/47495801965KS.jpeg)
48445501615KS: Brak obrazka w bazie Azymuta.
49282501184KS: Brak obrazka w bazie Azymuta.
49596001579KS: Pobrano obrazek.(/media/books/49596001579KS.jpeg)
49686001350KS: Pobrano obrazek.(/media/books/49686001350KS.jpeg)
49974001615KS: Pobrano obrazek.(/media/books/49974001615KS.jpeg)
50090000207KS: Pobrano obrazek.(/media/books/50090000207KS.jpeg)
50256601579KS: Pobrano obrazek.(/media/books/50256601579KS.jpeg)
52775100231KS: Pobrano obrazek.(/media/books/52775100231KS.jpeg)
53308401041KS: Pobrano obrazek.(/media/books/53308401041KS.jpeg)
53650002269KS: Brak obrazka w bazie Azymuta.
54326401144KS: Pobrano obrazek.(/media/books/54326401144KS.jpeg)
55247402249KS: Brak obrazka w bazie Azymuta.
55250302062KS: Brak obrazka w bazie Azymuta.
57158801622KS: Pobrano obrazek.(/media/books/57158801622KS.jpeg)
57575602706KS: Pobrano obrazek.(/media/books/57575602706KS.jpeg)
58264602706KS: Pobrano obrazek.(/media/books/58264602706KS.jpeg)
60139002894KS: Pobrano obrazek.(/media/books/60139002894KS.jpeg)
60143302894KS: Pobrano obrazek.(/media/books/60143302894KS.jpeg)
60159902894KS: Pobrano obrazek.(/media/books/60159902894KS.jpeg)
60160802894KS: Pobrano obrazek.(/media/books/60160802894KS.jpeg)
60161202894KS: Brak obrazka w bazie Azymuta.
61274601830KS: Brak obrazka w bazie Azymuta.
61829501075KS: Brak obrazka w bazie Azymuta.
61977702706KS: Brak obrazka w bazie Azymuta.
62104401430KS: Pobrano obrazek.(/media/books/62104401430KS.jpeg)
63614801262KS: Brak obrazka w bazie Azymuta.
64253303114KS: Brak obrazka w bazie Azymuta.
64894500149KS: Brak obrazka w bazie Azymuta.
65196601622KS: Brak obrazka w bazie Azymuta.
65392002743KS: Brak obrazka w bazie Azymuta.
66167802894KS: Brak obrazka w bazie Azymuta.
66338102894KS: Brak obrazka w bazie Azymuta.
66690002894KS: Brak obrazka w bazie Azymuta.
66988102894KS: Brak obrazka w bazie Azymuta.
67454302494KS: Brak obrazka w bazie Azymuta.
67848500153KS: Pobrano obrazek.(/media/books/67848500153KS.jpeg)
68804402044KS: Pobrano obrazek.(/media/books/68804402044KS.jpeg)
70217100206KS: Brak obrazka w bazie Azymuta.
70217400206KS: Brak obrazka w bazie Azymuta.
70227603326KS: Pobrano obrazek.(/media/books/70227603326KS.jpeg)
70341400124KS: Pobrano obrazek.(/media/books/70341400124KS.jpeg)
70360802389KS: Pobrano obrazek.(/media/books/70360802389KS.jpeg)
70362502608KS: Pobrano obrazek.(/media/books/70362502608KS.jpeg)
70486401049KS: Pobrano obrazek.(/media/books/70486401049KS.jpeg)
70491003053KS: Pobrano obrazek.(/media/books/70491003053KS.jpeg)
70491203053KS: Brak obrazka w bazie Azymuta.
70526003143KS: Pobrano obrazek.(/media/books/70526003143KS.jpeg)
70526701252KS: Brak obrazka w bazie Azymuta.
70530302894KS: Brak obrazka w bazie Azymuta.
70550401646KS: Brak obrazka w bazie Azymuta.
70551601405KS: Brak obrazka w bazie Azymuta.
70557401144KS: Brak obrazka w bazie Azymuta.
70559601648KS: Pobrano obrazek.(/media/books/70559601648KS.jpeg)
70649402608KS: Brak obrazka w bazie Azymuta.
70658902608KS: Brak obrazka w bazie Azymuta.
70662201184KS: Brak obrazka w bazie Azymuta.
70682202798KS: Brak obrazka w bazie Azymuta.
70685101549KS: Brak obrazka w bazie Azymuta.
70689500208KS: Pobrano obrazek.(/media/books/70689500208KS.jpeg)
70693701252KS: Brak obrazka w bazie Azymuta.
70695103053KS: Brak obrazka w bazie Azymuta.
70719900208KS: Pobrano obrazek.(/media/books/70719900208KS.jpeg)
70720100208KS: Brak obrazka w bazie Azymuta.
70720200208KS: Pobrano obrazek.(/media/books/70720200208KS.jpeg)
70720400208KS: Pobrano obrazek.(/media/books/70720400208KS.jpeg)
70740003022KS: Pobrano obrazek.(/media/books/70740003022KS.jpeg)
70744600203KS: Pobrano obrazek.(/media/books/70744600203KS.jpeg)
70753403053KS: Pobrano obrazek.(/media/books/70753403053KS.jpeg)
70755102370KS: Pobrano obrazek.(/media/books/70755102370KS.jpeg)
70755302370KS: Pobrano obrazek.(/media/books/70755302370KS.jpeg)
70761603133KS: Brak obrazka w bazie Azymuta.
Transakcja 11145-1424312459597
Pobrano 107534 dostepnosci.
Pobrano 134930 cen.
Usuniecie 4243ID:
37100801579KS
ID:29376
37100801579KS
Tytuł: MW
ISBN: 839176124X
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
2 kategorii do przypisania.
2Kategorii zapisano.
Zapisano 37100801579KS .
37100801579KS
MW
Koniec produktu.
Usuniecie 4906ID:
41595401615KS
ID:29376
41595401615KS
Tytuł: Historia polityczna świata XX w t1 1901-1945
ISBN: 8323318522
Debug: Path - FALSE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
MagentoError: Image does not exist.7 kategorii do przypisania.
7Kategorii zapisano.
Zapisano 41595401615KS .
41595401615KS
Historia polityczna świata XX w t1 1901-1945
Koniec produktu.
Usuniecie 4974ID:
41976601579KS
ID:29376
41976601579KS
Tytuł: Salon 2. Alfabet szulerów. Część pierwsza A-L
ISBN: 8360297118
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
3 kategorii do przypisania.
3Kategorii zapisano.
Zapisano 41976601579KS .
41976601579KS
Salon 2. Alfabet szulerów. Część pierwsza A-L
Koniec produktu.
Usuniecie 2240ID:
42172001579KS
ID:29376
42172001579KS
Tytuł: Salon 2 Alfabet szulerów
ISBN: 8360297126
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
3 kategorii do przypisania.
3Kategorii zapisano.
Zapisano 42172001579KS .
42172001579KS
Salon 2 Alfabet szulerów
Koniec produktu.
Usuniecie 5376ID:
43471102044KS
ID:29376
43471102044KS
Tytuł: Tajemnica Las Meninas
ISBN: 9788389368737
Debug: Path - FALSE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
MagentoError: Image does not exist.2 kategorii do przypisania.
2Kategorii zapisano.
Zapisano 43471102044KS .
43471102044KS
Tajemnica Las Meninas
Koniec produktu.
Koniec transakcji.
</code>









share|improve this question
















I have written a simple script that downloads an XML with product info from a wholesale parse it and save new products or updates exiting ones. It has been working for a few months, but now it's getting really strange. It updates existing products correctly, but it doesn't add a new ones (no error at all) or it overwrites an existing product with the new ones data. I've been trying to find any clue, to debug I output almost any valuable info, but it just won't work.



This is my script:



<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
require_once('Kategorie.php');
$kat = new Kategorie();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$product = Mage::getModel('catalog/product');

$xml=simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getdb&id=XX&p=XX") or die("Error: Cannot create object ksiazki");
//$xml=simplexml_load_file("testdb.xml");

$ksiazki = array();
$dostepnosc = array();
$ceny = array();

echo count($xml->books->book)." książek pobrano.<br>";

if (count($xml->books->book) > 0)

foreach ($xml->books->book as $book)

if ($book->attributes()->dzial == "KC")

if ($kat->isIndexHistoric((string)$book->attributes()->indeks))

array_push($ksiazki, $book);

//pobieranie obrazow
$url = "http://services.azymut.pl/oferta/servlet/?mode=getImg&indeks=".$book->attributes()->indeks."&id=XX&p=XX";
$path = dirname(__FILE__)."/media/books/".$book->attributes()->indeks.".jpeg";
$urlFile = "/media/books/".$book->attributes()->indeks.".jpeg";
try

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$img = curl_exec($curl);
curl_close($curl);
$data = imagecreatefromstring($img);
if (isset($data))

imagejpeg($data,$path);


catch(Exception $e)

echo "MagentoError: ".$e->getMessage();
Mage::log($e->getMessage());


echo $book->attributes()->indeks.": ".(file_exists($path) ? "Pobrano obrazek.(/media/books/".$book->attributes()->indeks.".jpeg)<br>" : "Brak obrazka w bazie Azymuta.<br>");




$transakcja = $xml->attributes()->transactionId;
echo "Transakcja ".$xml->attributes()->transactionId."<br>";

$xml2 = simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getAvail&id=XX&p=XX") or die("Error: Cannot create object dostepnosc");

foreach ($xml2->book as $book)

$index = (string)$book->attributes()->indeks;
$dostepnosc[$index] = intval($book->attributes()->p);


echo "Pobrano ".count($dostepnosc)." dostepnosci.<br>";

$xml2 = simplexml_load_file("http://services.azymut.pl/oferta/servlet/?mode=getPrice&id=XX&p=XX") or die("Error: Cannot create object ceny");

foreach ($xml2->book as $book)

$index = (string)$book->attributes()->indeks;
$ceny[$index] = $book->attributes()->cena;
$ceny[$index] = 1.30 * $ceny[$index]; //marza 30%
$ceny[$index] = 1.05 * $ceny[$index]; //vat 5%
$ceny[$index] = round($ceny[$index], 1);


echo "Pobrano ".count($ceny)." cen.<br>";

for ($i = 0;$i < count($ksiazki);$i++)



if ($i == count($ksiazki) - 1 || count($xml->books->book) == 0 || count($ksiazki == 0))

//file_get_contents("http://services.azymut.pl/oferta/servlet/?mode=confirm&id=XX&p=XX&transactionId=".$transakcja) or die("Error: Cannot create object confirmation");
echo "Koniec transakcji.<br>";



?>



Why Am I deleting the products at the beginning? It was just one of my blind shots, I wanted to start fresh, but the result was: none of the 500 products has been saved.



And here is the example of the output:



<code>
500 książek pobrano.
37100801579KS: Pobrano obrazek.(/media/books/37100801579KS.jpeg)
41595401615KS: Brak obrazka w bazie Azymuta.
41976601579KS: Pobrano obrazek.(/media/books/41976601579KS.jpeg)
42172001579KS: Pobrano obrazek.(/media/books/42172001579KS.jpeg)
43471102044KS: Brak obrazka w bazie Azymuta.
47354301615KS: Pobrano obrazek.(/media/books/47354301615KS.jpeg)
47359102056KS: Pobrano obrazek.(/media/books/47359102056KS.jpeg)
47495801965KS: Pobrano obrazek.(/media/books/47495801965KS.jpeg)
48445501615KS: Brak obrazka w bazie Azymuta.
49282501184KS: Brak obrazka w bazie Azymuta.
49596001579KS: Pobrano obrazek.(/media/books/49596001579KS.jpeg)
49686001350KS: Pobrano obrazek.(/media/books/49686001350KS.jpeg)
49974001615KS: Pobrano obrazek.(/media/books/49974001615KS.jpeg)
50090000207KS: Pobrano obrazek.(/media/books/50090000207KS.jpeg)
50256601579KS: Pobrano obrazek.(/media/books/50256601579KS.jpeg)
52775100231KS: Pobrano obrazek.(/media/books/52775100231KS.jpeg)
53308401041KS: Pobrano obrazek.(/media/books/53308401041KS.jpeg)
53650002269KS: Brak obrazka w bazie Azymuta.
54326401144KS: Pobrano obrazek.(/media/books/54326401144KS.jpeg)
55247402249KS: Brak obrazka w bazie Azymuta.
55250302062KS: Brak obrazka w bazie Azymuta.
57158801622KS: Pobrano obrazek.(/media/books/57158801622KS.jpeg)
57575602706KS: Pobrano obrazek.(/media/books/57575602706KS.jpeg)
58264602706KS: Pobrano obrazek.(/media/books/58264602706KS.jpeg)
60139002894KS: Pobrano obrazek.(/media/books/60139002894KS.jpeg)
60143302894KS: Pobrano obrazek.(/media/books/60143302894KS.jpeg)
60159902894KS: Pobrano obrazek.(/media/books/60159902894KS.jpeg)
60160802894KS: Pobrano obrazek.(/media/books/60160802894KS.jpeg)
60161202894KS: Brak obrazka w bazie Azymuta.
61274601830KS: Brak obrazka w bazie Azymuta.
61829501075KS: Brak obrazka w bazie Azymuta.
61977702706KS: Brak obrazka w bazie Azymuta.
62104401430KS: Pobrano obrazek.(/media/books/62104401430KS.jpeg)
63614801262KS: Brak obrazka w bazie Azymuta.
64253303114KS: Brak obrazka w bazie Azymuta.
64894500149KS: Brak obrazka w bazie Azymuta.
65196601622KS: Brak obrazka w bazie Azymuta.
65392002743KS: Brak obrazka w bazie Azymuta.
66167802894KS: Brak obrazka w bazie Azymuta.
66338102894KS: Brak obrazka w bazie Azymuta.
66690002894KS: Brak obrazka w bazie Azymuta.
66988102894KS: Brak obrazka w bazie Azymuta.
67454302494KS: Brak obrazka w bazie Azymuta.
67848500153KS: Pobrano obrazek.(/media/books/67848500153KS.jpeg)
68804402044KS: Pobrano obrazek.(/media/books/68804402044KS.jpeg)
70217100206KS: Brak obrazka w bazie Azymuta.
70217400206KS: Brak obrazka w bazie Azymuta.
70227603326KS: Pobrano obrazek.(/media/books/70227603326KS.jpeg)
70341400124KS: Pobrano obrazek.(/media/books/70341400124KS.jpeg)
70360802389KS: Pobrano obrazek.(/media/books/70360802389KS.jpeg)
70362502608KS: Pobrano obrazek.(/media/books/70362502608KS.jpeg)
70486401049KS: Pobrano obrazek.(/media/books/70486401049KS.jpeg)
70491003053KS: Pobrano obrazek.(/media/books/70491003053KS.jpeg)
70491203053KS: Brak obrazka w bazie Azymuta.
70526003143KS: Pobrano obrazek.(/media/books/70526003143KS.jpeg)
70526701252KS: Brak obrazka w bazie Azymuta.
70530302894KS: Brak obrazka w bazie Azymuta.
70550401646KS: Brak obrazka w bazie Azymuta.
70551601405KS: Brak obrazka w bazie Azymuta.
70557401144KS: Brak obrazka w bazie Azymuta.
70559601648KS: Pobrano obrazek.(/media/books/70559601648KS.jpeg)
70649402608KS: Brak obrazka w bazie Azymuta.
70658902608KS: Brak obrazka w bazie Azymuta.
70662201184KS: Brak obrazka w bazie Azymuta.
70682202798KS: Brak obrazka w bazie Azymuta.
70685101549KS: Brak obrazka w bazie Azymuta.
70689500208KS: Pobrano obrazek.(/media/books/70689500208KS.jpeg)
70693701252KS: Brak obrazka w bazie Azymuta.
70695103053KS: Brak obrazka w bazie Azymuta.
70719900208KS: Pobrano obrazek.(/media/books/70719900208KS.jpeg)
70720100208KS: Brak obrazka w bazie Azymuta.
70720200208KS: Pobrano obrazek.(/media/books/70720200208KS.jpeg)
70720400208KS: Pobrano obrazek.(/media/books/70720400208KS.jpeg)
70740003022KS: Pobrano obrazek.(/media/books/70740003022KS.jpeg)
70744600203KS: Pobrano obrazek.(/media/books/70744600203KS.jpeg)
70753403053KS: Pobrano obrazek.(/media/books/70753403053KS.jpeg)
70755102370KS: Pobrano obrazek.(/media/books/70755102370KS.jpeg)
70755302370KS: Pobrano obrazek.(/media/books/70755302370KS.jpeg)
70761603133KS: Brak obrazka w bazie Azymuta.
Transakcja 11145-1424312459597
Pobrano 107534 dostepnosci.
Pobrano 134930 cen.
Usuniecie 4243ID:
37100801579KS
ID:29376
37100801579KS
Tytuł: MW
ISBN: 839176124X
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
2 kategorii do przypisania.
2Kategorii zapisano.
Zapisano 37100801579KS .
37100801579KS
MW
Koniec produktu.
Usuniecie 4906ID:
41595401615KS
ID:29376
41595401615KS
Tytuł: Historia polityczna świata XX w t1 1901-1945
ISBN: 8323318522
Debug: Path - FALSE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
MagentoError: Image does not exist.7 kategorii do przypisania.
7Kategorii zapisano.
Zapisano 41595401615KS .
41595401615KS
Historia polityczna świata XX w t1 1901-1945
Koniec produktu.
Usuniecie 4974ID:
41976601579KS
ID:29376
41976601579KS
Tytuł: Salon 2. Alfabet szulerów. Część pierwsza A-L
ISBN: 8360297118
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
3 kategorii do przypisania.
3Kategorii zapisano.
Zapisano 41976601579KS .
41976601579KS
Salon 2. Alfabet szulerów. Część pierwsza A-L
Koniec produktu.
Usuniecie 2240ID:
42172001579KS
ID:29376
42172001579KS
Tytuł: Salon 2 Alfabet szulerów
ISBN: 8360297126
Debug: Path - TRUE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
Dodano obrazek.
3 kategorii do przypisania.
3Kategorii zapisano.
Zapisano 42172001579KS .
42172001579KS
Salon 2 Alfabet szulerów
Koniec produktu.
Usuniecie 5376ID:
43471102044KS
ID:29376
43471102044KS
Tytuł: Tajemnica Las Meninas
ISBN: 9788389368737
Debug: Path - FALSE Path2 - TRUE Liczba obrazkow - 0 Aktualizacja - FALSE
MagentoError: Image does not exist.2 kategorii do przypisania.
2Kategorii zapisano.
Zapisano 43471102044KS .
43471102044KS
Tajemnica Las Meninas
Koniec produktu.
Koniec transakcji.
</code>






php products script






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 31 mins ago









Teja Bhagavan Kollepara

3,00641949




3,00641949










asked Feb 19 '15 at 2:50









Richard RahlRichard Rahl

11




11












  • Do you have a store with id 4 in your site?

    – Girish SH
    Feb 19 '15 at 2:55











  • Yes, but it doesn't work on any ID and even if I comment this line. Note one weird fact: every "saved" object in this example output has exactly the same ID. I dont know why. It's this line for example: 41976601579KS ID:29376 <- this is the ID of every product and it's the same! 41976601579KS

    – Richard Rahl
    Feb 19 '15 at 3:08


















  • Do you have a store with id 4 in your site?

    – Girish SH
    Feb 19 '15 at 2:55











  • Yes, but it doesn't work on any ID and even if I comment this line. Note one weird fact: every "saved" object in this example output has exactly the same ID. I dont know why. It's this line for example: 41976601579KS ID:29376 <- this is the ID of every product and it's the same! 41976601579KS

    – Richard Rahl
    Feb 19 '15 at 3:08

















Do you have a store with id 4 in your site?

– Girish SH
Feb 19 '15 at 2:55





Do you have a store with id 4 in your site?

– Girish SH
Feb 19 '15 at 2:55













Yes, but it doesn't work on any ID and even if I comment this line. Note one weird fact: every "saved" object in this example output has exactly the same ID. I dont know why. It's this line for example: 41976601579KS ID:29376 <- this is the ID of every product and it's the same! 41976601579KS

– Richard Rahl
Feb 19 '15 at 3:08






Yes, but it doesn't work on any ID and even if I comment this line. Note one weird fact: every "saved" object in this example output has exactly the same ID. I dont know why. It's this line for example: 41976601579KS ID:29376 <- this is the ID of every product and it's the same! 41976601579KS

– Richard Rahl
Feb 19 '15 at 3:08











1 Answer
1






active

oldest

votes


















1














I can't run this since I don't have your XML or the rest of your code but based on what you've described as your problem one thing stands out to me.



Starting here:



 echo "ID:".$product->getIdBySku($index)."<br>";

//// I get this part because you're loading your existing product.

if($product->getIdBySku($index) != NULL)

$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
$mediaCount = count($product->getMediaGalleryImages());
$date = date('d/m/Y h:i:s', strtotime($product->getCreatedAt()));

$aktualizacja = TRUE;
echo "Książka już istnieje, następuje nadpisywanie. Liczba obrazków książki to: ".$mediaCount.".<br>";


else


//// This part is redundant. You're doing this again below after this section.

$product->setSku($index)->setIsbn($ksiazki[$i]->isbn)->setName($ksiazki[$i]->tytul)->save();
$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
echo $product->getSku()."<br>";
echo "ID:".$product->getIdBySku($index)."<br>";



Try replacing the code above with this:



 echo "ID:".$product->getIdBySku($index)."<br>";

if($product->getIdBySku($index) != NULL)

$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
$mediaCount = count($product->getMediaGalleryImages());
$date = date('d/m/Y h:i:s', strtotime($product->getCreatedAt()));

$aktualizacja = TRUE;
echo "Książka już istnieje, następuje nadpisywanie. Liczba obrazków książki to: ".$mediaCount.".<br>";


else


$product = Mage::getModel('catalog/product');







share|improve this answer

























  • It looks like it worked, the product has been added. That's funny because this "else" was added when I tried to figure this problem out, before I posted here. : D Anyway, there is one problem now, the photos are loaded into the product, but they are not "checked" as base, small and thumbnail. Strange.

    – Richard Rahl
    Feb 19 '15 at 16:56











  • Oh, no I have examined this further and the products are saved, but they are mixed up? When I look for SKU of one book in magento backend, there is completly another book with that SKU.

    – Richard Rahl
    Feb 19 '15 at 17:01











  • You do need that else. If not then it will save incorrectly. Try re-adding it exactly how I had it in my answer.

    – seanbreeden
    Feb 19 '15 at 17:12











  • Still some of the products are mixed up, what I mean is: there are a few exactly identical products, but with a different SKU, although they were saved as 2 different products (I'm sure, because I echo all the essential values during the process). Also the images are saved, but they are not "checked" as base image, small image and thumbnail - the effect is they have no image in the frontend.

    – Richard Rahl
    Feb 19 '15 at 18:37










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f57789%2fcannot-add-new-products-or-they-get-mixed-up-with-updated-ones-no-error%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I can't run this since I don't have your XML or the rest of your code but based on what you've described as your problem one thing stands out to me.



Starting here:



 echo "ID:".$product->getIdBySku($index)."<br>";

//// I get this part because you're loading your existing product.

if($product->getIdBySku($index) != NULL)

$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
$mediaCount = count($product->getMediaGalleryImages());
$date = date('d/m/Y h:i:s', strtotime($product->getCreatedAt()));

$aktualizacja = TRUE;
echo "Książka już istnieje, następuje nadpisywanie. Liczba obrazków książki to: ".$mediaCount.".<br>";


else


//// This part is redundant. You're doing this again below after this section.

$product->setSku($index)->setIsbn($ksiazki[$i]->isbn)->setName($ksiazki[$i]->tytul)->save();
$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
echo $product->getSku()."<br>";
echo "ID:".$product->getIdBySku($index)."<br>";



Try replacing the code above with this:



 echo "ID:".$product->getIdBySku($index)."<br>";

if($product->getIdBySku($index) != NULL)

$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
$mediaCount = count($product->getMediaGalleryImages());
$date = date('d/m/Y h:i:s', strtotime($product->getCreatedAt()));

$aktualizacja = TRUE;
echo "Książka już istnieje, następuje nadpisywanie. Liczba obrazków książki to: ".$mediaCount.".<br>";


else


$product = Mage::getModel('catalog/product');







share|improve this answer

























  • It looks like it worked, the product has been added. That's funny because this "else" was added when I tried to figure this problem out, before I posted here. : D Anyway, there is one problem now, the photos are loaded into the product, but they are not "checked" as base, small and thumbnail. Strange.

    – Richard Rahl
    Feb 19 '15 at 16:56











  • Oh, no I have examined this further and the products are saved, but they are mixed up? When I look for SKU of one book in magento backend, there is completly another book with that SKU.

    – Richard Rahl
    Feb 19 '15 at 17:01











  • You do need that else. If not then it will save incorrectly. Try re-adding it exactly how I had it in my answer.

    – seanbreeden
    Feb 19 '15 at 17:12











  • Still some of the products are mixed up, what I mean is: there are a few exactly identical products, but with a different SKU, although they were saved as 2 different products (I'm sure, because I echo all the essential values during the process). Also the images are saved, but they are not "checked" as base image, small image and thumbnail - the effect is they have no image in the frontend.

    – Richard Rahl
    Feb 19 '15 at 18:37















1














I can't run this since I don't have your XML or the rest of your code but based on what you've described as your problem one thing stands out to me.



Starting here:



 echo "ID:".$product->getIdBySku($index)."<br>";

//// I get this part because you're loading your existing product.

if($product->getIdBySku($index) != NULL)

$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
$mediaCount = count($product->getMediaGalleryImages());
$date = date('d/m/Y h:i:s', strtotime($product->getCreatedAt()));

$aktualizacja = TRUE;
echo "Książka już istnieje, następuje nadpisywanie. Liczba obrazków książki to: ".$mediaCount.".<br>";


else


//// This part is redundant. You're doing this again below after this section.

$product->setSku($index)->setIsbn($ksiazki[$i]->isbn)->setName($ksiazki[$i]->tytul)->save();
$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
echo $product->getSku()."<br>";
echo "ID:".$product->getIdBySku($index)."<br>";



Try replacing the code above with this:



 echo "ID:".$product->getIdBySku($index)."<br>";

if($product->getIdBySku($index) != NULL)

$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
$mediaCount = count($product->getMediaGalleryImages());
$date = date('d/m/Y h:i:s', strtotime($product->getCreatedAt()));

$aktualizacja = TRUE;
echo "Książka już istnieje, następuje nadpisywanie. Liczba obrazków książki to: ".$mediaCount.".<br>";


else


$product = Mage::getModel('catalog/product');







share|improve this answer

























  • It looks like it worked, the product has been added. That's funny because this "else" was added when I tried to figure this problem out, before I posted here. : D Anyway, there is one problem now, the photos are loaded into the product, but they are not "checked" as base, small and thumbnail. Strange.

    – Richard Rahl
    Feb 19 '15 at 16:56











  • Oh, no I have examined this further and the products are saved, but they are mixed up? When I look for SKU of one book in magento backend, there is completly another book with that SKU.

    – Richard Rahl
    Feb 19 '15 at 17:01











  • You do need that else. If not then it will save incorrectly. Try re-adding it exactly how I had it in my answer.

    – seanbreeden
    Feb 19 '15 at 17:12











  • Still some of the products are mixed up, what I mean is: there are a few exactly identical products, but with a different SKU, although they were saved as 2 different products (I'm sure, because I echo all the essential values during the process). Also the images are saved, but they are not "checked" as base image, small image and thumbnail - the effect is they have no image in the frontend.

    – Richard Rahl
    Feb 19 '15 at 18:37













1












1








1







I can't run this since I don't have your XML or the rest of your code but based on what you've described as your problem one thing stands out to me.



Starting here:



 echo "ID:".$product->getIdBySku($index)."<br>";

//// I get this part because you're loading your existing product.

if($product->getIdBySku($index) != NULL)

$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
$mediaCount = count($product->getMediaGalleryImages());
$date = date('d/m/Y h:i:s', strtotime($product->getCreatedAt()));

$aktualizacja = TRUE;
echo "Książka już istnieje, następuje nadpisywanie. Liczba obrazków książki to: ".$mediaCount.".<br>";


else


//// This part is redundant. You're doing this again below after this section.

$product->setSku($index)->setIsbn($ksiazki[$i]->isbn)->setName($ksiazki[$i]->tytul)->save();
$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
echo $product->getSku()."<br>";
echo "ID:".$product->getIdBySku($index)."<br>";



Try replacing the code above with this:



 echo "ID:".$product->getIdBySku($index)."<br>";

if($product->getIdBySku($index) != NULL)

$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
$mediaCount = count($product->getMediaGalleryImages());
$date = date('d/m/Y h:i:s', strtotime($product->getCreatedAt()));

$aktualizacja = TRUE;
echo "Książka już istnieje, następuje nadpisywanie. Liczba obrazków książki to: ".$mediaCount.".<br>";


else


$product = Mage::getModel('catalog/product');







share|improve this answer















I can't run this since I don't have your XML or the rest of your code but based on what you've described as your problem one thing stands out to me.



Starting here:



 echo "ID:".$product->getIdBySku($index)."<br>";

//// I get this part because you're loading your existing product.

if($product->getIdBySku($index) != NULL)

$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
$mediaCount = count($product->getMediaGalleryImages());
$date = date('d/m/Y h:i:s', strtotime($product->getCreatedAt()));

$aktualizacja = TRUE;
echo "Książka już istnieje, następuje nadpisywanie. Liczba obrazków książki to: ".$mediaCount.".<br>";


else


//// This part is redundant. You're doing this again below after this section.

$product->setSku($index)->setIsbn($ksiazki[$i]->isbn)->setName($ksiazki[$i]->tytul)->save();
$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
echo $product->getSku()."<br>";
echo "ID:".$product->getIdBySku($index)."<br>";



Try replacing the code above with this:



 echo "ID:".$product->getIdBySku($index)."<br>";

if($product->getIdBySku($index) != NULL)

$product = Mage::getModel('catalog/product')->load($product->getIdBySku($index));
$mediaCount = count($product->getMediaGalleryImages());
$date = date('d/m/Y h:i:s', strtotime($product->getCreatedAt()));

$aktualizacja = TRUE;
echo "Książka już istnieje, następuje nadpisywanie. Liczba obrazków książki to: ".$mediaCount.".<br>";


else


$product = Mage::getModel('catalog/product');








share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 22 '15 at 6:05









Keyul Shah

6,56963058




6,56963058










answered Feb 19 '15 at 3:58









seanbreedenseanbreeden

2,7041323




2,7041323












  • It looks like it worked, the product has been added. That's funny because this "else" was added when I tried to figure this problem out, before I posted here. : D Anyway, there is one problem now, the photos are loaded into the product, but they are not "checked" as base, small and thumbnail. Strange.

    – Richard Rahl
    Feb 19 '15 at 16:56











  • Oh, no I have examined this further and the products are saved, but they are mixed up? When I look for SKU of one book in magento backend, there is completly another book with that SKU.

    – Richard Rahl
    Feb 19 '15 at 17:01











  • You do need that else. If not then it will save incorrectly. Try re-adding it exactly how I had it in my answer.

    – seanbreeden
    Feb 19 '15 at 17:12











  • Still some of the products are mixed up, what I mean is: there are a few exactly identical products, but with a different SKU, although they were saved as 2 different products (I'm sure, because I echo all the essential values during the process). Also the images are saved, but they are not "checked" as base image, small image and thumbnail - the effect is they have no image in the frontend.

    – Richard Rahl
    Feb 19 '15 at 18:37

















  • It looks like it worked, the product has been added. That's funny because this "else" was added when I tried to figure this problem out, before I posted here. : D Anyway, there is one problem now, the photos are loaded into the product, but they are not "checked" as base, small and thumbnail. Strange.

    – Richard Rahl
    Feb 19 '15 at 16:56











  • Oh, no I have examined this further and the products are saved, but they are mixed up? When I look for SKU of one book in magento backend, there is completly another book with that SKU.

    – Richard Rahl
    Feb 19 '15 at 17:01











  • You do need that else. If not then it will save incorrectly. Try re-adding it exactly how I had it in my answer.

    – seanbreeden
    Feb 19 '15 at 17:12











  • Still some of the products are mixed up, what I mean is: there are a few exactly identical products, but with a different SKU, although they were saved as 2 different products (I'm sure, because I echo all the essential values during the process). Also the images are saved, but they are not "checked" as base image, small image and thumbnail - the effect is they have no image in the frontend.

    – Richard Rahl
    Feb 19 '15 at 18:37
















It looks like it worked, the product has been added. That's funny because this "else" was added when I tried to figure this problem out, before I posted here. : D Anyway, there is one problem now, the photos are loaded into the product, but they are not "checked" as base, small and thumbnail. Strange.

– Richard Rahl
Feb 19 '15 at 16:56





It looks like it worked, the product has been added. That's funny because this "else" was added when I tried to figure this problem out, before I posted here. : D Anyway, there is one problem now, the photos are loaded into the product, but they are not "checked" as base, small and thumbnail. Strange.

– Richard Rahl
Feb 19 '15 at 16:56













Oh, no I have examined this further and the products are saved, but they are mixed up? When I look for SKU of one book in magento backend, there is completly another book with that SKU.

– Richard Rahl
Feb 19 '15 at 17:01





Oh, no I have examined this further and the products are saved, but they are mixed up? When I look for SKU of one book in magento backend, there is completly another book with that SKU.

– Richard Rahl
Feb 19 '15 at 17:01













You do need that else. If not then it will save incorrectly. Try re-adding it exactly how I had it in my answer.

– seanbreeden
Feb 19 '15 at 17:12





You do need that else. If not then it will save incorrectly. Try re-adding it exactly how I had it in my answer.

– seanbreeden
Feb 19 '15 at 17:12













Still some of the products are mixed up, what I mean is: there are a few exactly identical products, but with a different SKU, although they were saved as 2 different products (I'm sure, because I echo all the essential values during the process). Also the images are saved, but they are not "checked" as base image, small image and thumbnail - the effect is they have no image in the frontend.

– Richard Rahl
Feb 19 '15 at 18:37





Still some of the products are mixed up, what I mean is: there are a few exactly identical products, but with a different SKU, although they were saved as 2 different products (I'm sure, because I echo all the essential values during the process). Also the images are saved, but they are not "checked" as base image, small image and thumbnail - the effect is they have no image in the frontend.

– Richard Rahl
Feb 19 '15 at 18:37

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f57789%2fcannot-add-new-products-or-they-get-mixed-up-with-updated-ones-no-error%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Nidaros erkebispedøme

Birsay

Was Woodrow Wilson really a Liberal?Was World War I a war of liberals against authoritarians?Founding Fathers...