Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Php create xml
 
panagiotisGr
Jr. Member
 
Total Posts:  16
Joined:  2009-09-29
 

Good afternoon,

I have made the following php that creates an xml.

my problem is in the category. I want to show the full path of categories for example if the product is a bike to see: Gym Equipment - Instruments for the home - Bicycles

any ideas?

<?php
header 
("content-type: text/xml");
require_once 
'app/Mage.php';
umask);
Mage::app(Mage::app()->getStore()); 
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$_productCollection Mage::getModel('catalog/product')->getCollection();
$_productCollection->addAttributeToSelect('*');
$baseUrl Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
//Begin the output
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo 
'<shopnvalue>';

//Loop through and print each products info

foreach ( $_productCollection as $row 

    $categoryIds 
$row->getCategoryIds();
    foreach(
$categoryIds as $categoryId{
    $category 
Mage::getModel('catalog/category/')->load($categoryId);
    
}
    
    $inStock 
Mage::getModel('cataloginventory/stock_item')->loadByProduct($row)->getIsInStock();
    if(
$inStock==1{
        $InStock
="Y";
    
else {
        $InStock
="N";
    
}
    
     $qty 
= (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
            if (
$qty 1{ $availability 'Άμεσα Î´Î¹Î±Î¸Î­ÏƒÎ¹Î¼Î¿'else { $availability 'in stock'}
            $product_data[
'availability']                         =    $availability
    
    
    if(
$row->getImage()== "no_selection"{
        $ImagePath
=$baseUrl."skin/frontend/base/default/images/no_image.jpg";
    
else {
        $ImagePath
=Mage::helper('catalog/product')->getImageUrl($row);
    
}
    
    
echo '<product>';
    echo 
'<id>'.$row->getSku().'</id>';
    echo 
'<name>'.htmlspecialchars($row->getName(), ENT_QUOTES).'</name>';
    echo 
'<link>'.htmlspecialchars($baseUrl.$row->geturlpath(), ENT_QUOTES).'</link>';
    echo 
'<image>'.htmlspecialchars($ImagePathENT_QUOTES).'</image>';
    echo 
'<category>'.htmlspecialchars($category->getName(), ENT_QUOTES).'</category>';
    echo 
'<Price>'.number_format($row->getPrice(),2).'</Price>';
    echo 
'<InStock>'.$InStock.'</InStock>';
    echo 
'<availability>'.$availability.'</availability>';
    echo 
'</product>';
    
}
   
echo '</shopnvalue>';
//Finish output
 
Magento Community Magento Community
Magento Community
Magento Community
 
panagiotisGr
Jr. Member
 
Total Posts:  16
Joined:  2009-09-29
 

I would really appreciate any help with this problem.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top