jonysi_d Posted October 17, 2012 Share Posted October 17, 2012 (edited) Hola.. tengo instalado un modulo que descarge de aquí que funciona bien. El problema és que necesito poder añadir el <pubDate> para poder publicar mis novedades en el muro de mi pagina de Facebook, pero no hay manera, a ver si podeis hecharme una mano, el codigo del archibo .xml lo tengo asi: <?xml version="1.0" encoding="UTF-8" ?> <module> <name>feeder</name> <displayName><![CDATA[RSS products feed]]></displayName> <version><![CDATA[0.2]]></version> <description><![CDATA[Generate a RSS products feed]]></description> <author><![CDATA[PrestaShop]]></author> <tab><![CDATA[front_office_features]]></tab> <is_configurable>0</is_configurable> <need_instance>0</need_instance> <limited_countries></limited_countries> </module> en mi archivo rss.php esta de la siguiente manera: <?php include(dirname(__FILE__).'/../../config/config.inc.php'); require_once(dirname(__FILE__).'/../../init.php'); // Get data $number = (intval(Tools::getValue('n')) ? intval(Tools::getValue('n')) : 10); $orderByValues = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position'); $orderWayValues = array(0 => 'ASC', 1 => 'DESC'); $orderBy = Tools::strtolower(Tools::getValue('orderby', $orderByValues[intval(Configuration::get('PS_PRODUCTS_ORDER_BY'))])); $orderWay = Tools::strtoupper(Tools::getValue('orderway', $orderWayValues[intval(Configuration::get('PS_PRODUCTS_ORDER_WAY'))])); if (!in_array($orderBy, $orderByValues)) $orderBy = $orderByValues[0]; if (!in_array($orderWay, $orderWayValues)) $orderWay = $orderWayValues[0]; $id_category = (intval(Tools::getValue('id_category')) ? intval(Tools::getValue('id_category')) : 1); $products = Product::getProducts(intval($cookie->id_lang), 0, ($number > 10 ? 10 : $number), $orderBy, $orderWay, $id_category, true); $currency = new Currency(intval($cookie->id_currency)); $affiliate = (Tools::getValue('ac') ? '?ac='.intval(Tools::getValue('ac')) : ''); $fecha = date('d-m-Y'); // Send feed header("Content-Type:text/xml; charset=utf-8"); echo '<?xml version="1.0" encoding="UTF-8"?>'."\n"; ?> <rss version="2.0"> <channel> <title><![CDATA[<?php echo Configuration::get('PS_SHOP_NAME') ?>]]></title> <link><?php echo _PS_BASE_URL_.__PS_BASE_URI__; ?></link> <mail><?php echo Configuration::get('PS_SHOP_EMAIL') ?></mail> <language><?php echo Language::getIsoById(intval($cookie->id_lang)); ?></language> <image> <title><![CDATA[<?php echo Configuration::get('PS_SHOP_NAME') ?>]]></title> <url><?php echo _PS_BASE_URL_.__PS_BASE_URI__.'img/logo.jpg'; ?></url> <link><?php echo _PS_BASE_URL_.__PS_BASE_URI__; ?></link> </image> <?php foreach ($products AS $product) { $image = Image::getImages(intval($cookie->id_lang), $product['id_product']); echo "\t\t<item>\n"; echo "\t\t\t<title><![CDATA[".$product['name']." - ".html_entity_decode(Tools::displayPrice(Product::getPriceStatic($product['id_product']), $currency), ENT_COMPAT, 'UTF-8')." ]]></title>\n"; echo "\t\t\t<description><img src=""._PS_BASE_URL_.__PS_BASE_URI__."img/p/".$image[0]['id_product']."-".$image[0]['id_image']."-small.jpg" title="".str_replace('&', '', $product['name'])."" alt="thumb" /> <![CDATA[".$product['description_short']."]]></description>\n"; echo "\t\t\t<link><![CDATA[".htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite(intval(Tools::getValue('id_category')), $cookie->id_lang))).$affiliate."]]></link>\n"; echo "\t\t</item>\n"; } ?> </channel> </rss> esta correcto ?? alguna sugerencia ?? se debe hacer la fecha con código dinámico ??? gracias Edited November 19, 2012 by jonysi_d (see edit history) Link to comment Share on other sites More sharing options...
jonysi_d Posted October 17, 2012 Author Share Posted October 17, 2012 solucionado: echo "\t\t<pubDate><![CDATA[0.2]]><?php echo date('d-m-Y h:i:s'); ?></pubDate>\n"; Link to comment Share on other sites More sharing options...
jonysi_d Posted November 19, 2012 Author Share Posted November 19, 2012 (edited) la verdad es que no lo he podido solucionar porque no me genera la noticia con la fecha en que se ha generado el producto o la noticia sino se genera la fecha del dia en que se visualiza o se hace click en el rss. Lo tengo asi.. pero no acaba de funcionar bien: <?php foreach ($products AS $product) { $image = Image::getImages(intval($cookie->id_lang), $product['id_product']); echo "\t\t<item>\n"; echo "\t\t\t<title><![CDATA[".$product['name']." - ".html_entity_decode(Tools::displayPrice(Product::getPriceStatic($product['id_product']), $currency), ENT_COMPAT, 'UTF-8')." ]]></title>\n"; echo "\t\t\t<description><img src=""._PS_BASE_URL_.__PS_BASE_URI__."img/p/".$image[0]['id_product']."-".$image[0]['id_image']."-small.jpg" title="".str_replace('&', '', $product['name'])."" alt="thumb" /> <![CDATA[".$product['description_short']."]]></description>\n"; echo "\t\t<pubDate><![CDATA[0.2]]><?php echo $fecha; ?></pubDate>\n"; echo "\t\t\t<link><![CDATA[".htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite(intval(Tools::getValue('id_category')), $cookie->id_lang))).$affiliate."]]></link>\n"; echo "\t\t</item>\n"; } ?> Edited November 19, 2012 by jonysi_d (see edit history) Link to comment Share on other sites More sharing options...
jonysi_d Posted November 19, 2012 Author Share Posted November 19, 2012 solucionado, estaba mal la sintaxi: echo "\t\t<pubDate><![CDATA[$fecha]]></pubDate>\n"; Link to comment Share on other sites More sharing options...
jonysi_d Posted November 19, 2012 Author Share Posted November 19, 2012 aunque ahora me pasa lo siguiente, cuando lo doy al linck de mi rss, se me abre en archibo xml pero no me abre los programas de rss , a que debe ser debido ?? os dejo el linck y este es mi código: <?php include(dirname(__FILE__).'/../../config/config.inc.php'); require_once(dirname(__FILE__).'/../../init.php'); // Get data $number = (intval(Tools::getValue('n')) ? intval(Tools::getValue('n')) : 10); $orderByValues = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position'); $orderWayValues = array(0 => 'ASC', 1 => 'DESC'); $orderBy = Tools::strtolower(Tools::getValue('orderby', $orderByValues[intval(Configuration::get('PS_PRODUCTS_ORDER_BY'))])); $orderWay = Tools::strtoupper(Tools::getValue('orderway', $orderWayValues[intval(Configuration::get('PS_PRODUCTS_ORDER_WAY'))])); if (!in_array($orderBy, $orderByValues)) $orderBy = $orderByValues[0]; if (!in_array($orderWay, $orderWayValues)) $orderWay = $orderWayValues[0]; $id_category = (intval(Tools::getValue('id_category')) ? intval(Tools::getValue('id_category')) : 1); $products = Product::getProducts(intval($cookie->id_lang), 0, ($number > 10 ? 10 : $number), $orderBy, $orderWay, $id_category, true); $currency = new Currency(intval($cookie->id_currency)); $affiliate = (Tools::getValue('ac') ? '?ac='.intval(Tools::getValue('ac')) : ''); // Send feed $fecha = date('d-m-Y'); // Send feed header("Content-Type:text/xml; charset=utf-8"); echo '<?xml version="1.0" encoding="UTF-8"?>'."\n"; ?> <rss version="2.0"> <channel> <title><![CDATA[<?php echo Configuration::get('PS_SHOP_NAME') ?>]]></title> <link><?php echo _PS_BASE_URL_.__PS_BASE_URI__; ?></link> <mail><?php echo Configuration::get('PS_SHOP_EMAIL') ?></mail> <generator>PrestaShop</generator> <language><?php echo Language::getIsoById(intval($cookie->id_lang)); ?></language> <image> <title><![CDATA[<?php echo Configuration::get('PS_SHOP_NAME') ?>]]></title> <url><?php echo _PS_BASE_URL_.__PS_BASE_URI__.'img/logo.jpg'; ?></url> <link><?php echo _PS_BASE_URL_.__PS_BASE_URI__; ?></link> </image> <?php foreach ($products AS $product) { $image = Image::getImages(intval($cookie->id_lang), $product['id_product']); echo "\t\t<item>\n"; echo "\t\t\t<title><![CDATA[".$product['name']." - ".html_entity_decode(Tools::displayPrice(Product::getPriceStatic($product['id_product']), $currency), ENT_COMPAT, 'UTF-8')." ]]></title>\n"; echo "\t\t\t<description><img src=""._PS_BASE_URL_.__PS_BASE_URI__."img/p/".$image[0]['id_product']."-".$image[0]['id_image']."-medium.jpg" title="".str_replace('&', '', $product['name'])."" alt="thumb" /> <![CDATA[".$product['description_short']."]]></description>\n"; echo "\t\t<pubDate><![CDATA[$fecha]]></pubDate>\n"; echo "\t\t\t<link><![CDATA[".htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite(intval(Tools::getValue('id_category')), $cookie->id_lang))).$affiliate."]]></link>\n"; echo "\t\t</item>\n"; } ?> </channel> </rss> Link to comment Share on other sites More sharing options...
jonysi_d Posted November 19, 2012 Author Share Posted November 19, 2012 el config.xml : <?xml version="1.0" encoding="UTF-8" ?> <module> <name>feeder</name> <displayName><![CDATA[RSS products feed]]></displayName> <version><![CDATA[0.2]]></version> <description><![CDATA[Generate a RSS products feed]]></description> <author><![CDATA[PrestaShop]]></author> <tab><![CDATA[front_office_features]]></tab> <is_configurable>0</is_configurable> <need_instance>0</need_instance> <limited_countries></limited_countries> </module> Link to comment Share on other sites More sharing options...
jonysi_d Posted December 7, 2012 Author Share Posted December 7, 2012 la solución es esta ( por si a alguien le sirve de ayuda): echo "\t\t<pubDate><![CDATA[".$product['date_upd']."]]></pubDate>\n"; Link to comment Share on other sites More sharing options...
Recommended Posts