вы можете получить параметр в Magento и использовать простой xml, чтобы превратить строку в xml
$xmlstr = self::XML_DECLARATION . urldecode($this->getRequest()->getParam('paramName');
try {
$xml = simplexml_load_string($xmlstr);
}
catch(Exception $ex) {
echo "Unable to process xml file because of the following error<br /><br /> $ex";
exit;
}
если это файл, который вы пытаетесь получить, вы можете настроить php-файл со следующим кодом, чтобы получить содержимое URL
function get_url_contents($url){
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
Вы можете использовать эту функцию, а затем, где в приведенном выше у нас было
$xmlstr = self::XML_DECLARATION . urldecode($this->getRequest()->getParam('paramName');
Вы должны быть в состоянии сделать это
$xmlstr = self::XML_DECLARATION . get_url_contents('http://urlhere.com/xml');
Тогда вы могли бы использовать простой XML и назначить узлы массиву продуктов, где вы могли бы иметь коллекцию продуктов, а затем выполнить цикл по ним и программно создать продукты в Magento с чем-то вроде этого, очевидно, изменив значения, жестко запрограммировано для всего, что вам может понадобиться.
$product = Mage::getSingleton('catalog/product');
// Build the product
$product->setSku($productData['sku']);
$product->setAttributeSetId(26);
$product->setTypeId('simple');
$product->setName($productData['description']);
$product->setCategoryIds(array(162));
$product->setWebsiteIDs(array(1));
$product->setDescription($productData['description']);
$product->setShortDescription($productData['description']);
$product->setPrice($productData['price']); # Set some price
$product->setWeight(4.0000);
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$product->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
$product->setData('is_salable', '1');
$product->setTaxClassId(2); # My default tax class
$product->setStockData(array(
'is_in_stock' => 1,
'qty' => 99999
));
try {
$product->save();
}
catch (Exception $ex) {
//Handle the error
}