danielle85 Posted January 27, 2014 Share Posted January 27, 2014 I would like to insert the category and subcategory of my products in the feed, but I can't figure out how to do it. This is the current code I use in rss.php: <?php /* * 2007-2011 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 1.4 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include(dirname(__FILE__).'/../../config/config.inc.php'); require_once(dirname(__FILE__).'/../../init.php'); // Get data $number = ((int)(Tools::getValue('n')) ? (int)(Tools::getValue('n')) : 10); $orderByValues = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity'); $orderWayValues = array(0 => 'ASC', 1 => 'DESC'); $orderBy = Tools::strtolower(Tools::getValue('orderby', $orderByValues[(int)(Configuration::get('PS_PRODUCTS_ORDER_BY'))])); $orderWay = Tools::strtoupper(Tools::getValue('orderway', $orderWayValues[(int)(Configuration::get('PS_PRODUCTS_ORDER_WAY'))])); if (!in_array($orderBy, $orderByValues)) $orderBy = $orderByValues[0]; if (!in_array($orderWay, $orderWayValues)) $orderWay = $orderWayValues[0]; $id_category = ((int)(Tools::getValue('id_category')) ? (int)(Tools::getValue('id_category')) : 1); $products = Product::getProducts((int)($cookie->id_lang), 0, NULL, 'id_product', 'ASC'); $currency = new Currency((int)($cookie->id_currency)); $affiliate = (Tools::getValue('ac') ? '?ac='.(int)(Tools::getValue('ac')) : ''); $id_category = ((int)(Tools::getValue('id_category')) ? (int)(Tools::getValue('id_category')) : 1); // Send feed header("Content-Type:text/xml; charset=utf-8"); echo '<?xml version="1.0" encoding="UTF-8"?>'."\n"; ?> <catalogus> <?php foreach ($products AS $product) { if ($product['active'] == 1){ $image = Image::getImages((int)($cookie->id_lang), $product['id_product']); echo "\t\t<product>\n"; // & in titel naar & omzetten echo "\t\t\t<Title>".str_replace("&", "&" , $product['name'])."</Title>\n"; echo "\t\t\t<Beschrijving>".str_replace("&", "&" , $product['description'])."</Beschrijving>\n"; echo "\t\t\t<Prijs>".html_entity_decode(Tools::displayPrice(Product::getPriceStatic($product['id_product']), $currency), ENT_COMPAT, 'UTF-8')."</Prijs>\n"; echo "\t\t\t<Categorie>"; $cats = Product::getProductCategories($product['id_product']); foreach ($cats AS $cat) { //home category niet tonen if($cat != 1){ $catnames = Category::getSimpleCategories($cookie->id_lang); foreach ($catnames as $catname){ if ($catname['id_category'] == $cat) echo $catname['name']; [spam-filter]} echo "</Categorie>\n"; echo "\t\t\t<Image-locatie>"; $cdata = true; if (is_array($image) AND sizeof($image)) { echo _PS_BASE_URL_.__PS_BASE_URI__."img/p/".$image[0]['id_product']."-".$image[0]['id_image']."-home.jpg"; $cdata = false; } echo "</Image-locatie>\n"; echo "\t\t\t<Portokosten>"; echo "0"; echo "</Portokosten>\n"; echo "\t\t\t<Levertijd>"; echo "1-2 werkdagen"; echo "</Levertijd>\n"; echo "\t\t\t<Winkelproductcode>"; echo $product['id_product']; echo "</Winkelproductcode>\n"; echo "\t\t\t<Deeplink>".htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite((int)($product['id_category_default']), $cookie->id_lang))).$affiliate."</Deeplink>\n"; echo "\t\t\t<Geslacht>"; echo "Dames"; echo "</Geslacht>\n"; echo "\t\t</product>\n"; } } ?> </catalogus> But there is something wrong with the category-part. I get the following error: This page contains the following errors: error on line 7 at column 27: xmlParseEntityRef: no name Below is a rendering of the page up to the first error. Can somebody help me out to show the (sub)category in the feed? Thanks! Link to comment Share on other sites More sharing options...
danielle85 Posted February 2, 2014 Author Share Posted February 2, 2014 Maybe I have to amke a connection with table "ps_category_lang"? The category is already named in the deeplink in the feed, but I can't display it in the feed, same for the subcategory. I use Prestashop 1.4.7.3. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now