3
我要出口從Magento的自定義XML飼料,這是下面的代碼我使用:
<?php
header('Content-Type: text/xml'); // XML's a handy dandy format
include '../app/Mage.php'; // Include the magento core
include 'ArrayXml.php';
Mage::app(); //And start up the Magento app
$_result = array(); // Make sure we have a result array to store our products
$_products = Mage::getModel('catalog/product')->getCollection();
foreach($_products as $_product) {
$_result['produs'][] = array(
'denumire' => $_product->getName(),
'descriere_scurta' => $_product->getShortDescription(), //product's short description
'descriere_lunga' => $_product->getDescription(), // product's long description
'pret_intreg' => $_product->getPrice(), //product's regular Price
'pret_redus' => $_product->getSpecialPrice(), //product's special Price
'url_produs' => $_product->getProductUrl(), //product url
'fotografie_produs' => $_product->getImageUrl() //product's image url
);
}
$_converter = new ArrayXML();
echo $_converter->toXML($_result);
然而,只有產品的URL和圖像URL是給我正確的值。剩下的都是空的。
什麼給?
這工作就像一個魅力。謝謝維塔利! –