我想从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);
Run Code Online (Sandbox Code Playgroud)
但是,只有产品URL和图像URL为我提供了正确的值.其余的都是空的.
是什么赋予了?
Vit*_*nov 11
'name'和其他是属性,所以你应该调用addAttributeToSelect:
$_products = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect(array(
'name',
'short_description',
'description'
))
->addPriceData();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7630 次 |
| 最近记录: |