Jump to content
nostradamus

[TUTORIAL] How to post new products on your facebook wall

Recommended Posts

How to post new products on your facebook wall tutorial

 

This is working for PrestaShop v1.4.7

 

First we will change the rrs to show new products

 

Open modules/feeder/rrs.php

 

Find

 

$orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
$orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));

 

Replace with

 

$orderByValues = array(0 => 'date_add', 1 => 'price', 2 => 'name', 3 => 'date_upd', 4 => 'position'); $orderWayValues = array(0 => 'DESC', 1 => 'ASC');

 

Find

 

$products = Product::getProducts(intval($cookie->id_lang), 0, ($number > 10 ? 10 : $number), $orderBy, $orderWay, $id_category, true);

 

Replace with

 

$products = Product::getNewProducts(intval($cookie->id_lang), 0, 10, false, 'date_add', 'DESC');

 

Now we need to add the pubdate for the product to the rss

 

Find

 

$image = Image::getImages((int)($cookie->id_lang), $product['id_product']);
 echo "\t\t<item>\n";

 

Add after on a new line

 

echo "\t\t\t<pubDate><![CDATA[".$product['date_add']." ]]></pubDate>\n";

 

If you want to use a bigger image for your facebook post

 

Find

 

echo "<![CDATA[<img src='"._PS_BASE_URL_._THEME_PROD_DIR_.$imageObj->getExistingImgPath()."-small.jpg' title='".str_replace('&', '', $product['name'])."' alt='thumb' />";

 

Replace with

 

echo "<![CDATA[<img src='"._PS_BASE_URL_._THEME_PROD_DIR_.$imageObj->getExistingImgPath()."-medium.jpg' title='".str_replace('&', '', $product['name'])."' alt='thumb' />";

 

Open modules/feeder/feeder.php

 

Find

 

'feedUrl' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/rss.php?id_category='.$id_category.'&orderby='.$orderBy.'&orderway='.$orderWay,

 

Replace with

 

'feedUrl' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/rss.php'));

 

 

 

Your done making changes to files. Save and upload the files to your server

 

Now got to modules and install RSS products feed

 

Now go to http://www.rssgraffiti.com/

 

And follow these steps to a make a basic setup tailored to your specifications http://www.rssgraffi...e_id=2081364848

 

The RSS url you need is www.your-site.com/modules/feeder/rss.php

 

When your done with the setup

 

RRS Graffiti will post your new products on your facebook wall

 

Demo

 

RSS Feed http://www.bijouxenz.../feeder/rss.php

 

Facebook page http://www.facebook....114295085294829

 

Dont forget to like the Facebook page ;)

 

 

UPDATE i added the modified files as a download

 

Extract the zip file and upload it to the modules folder

feeder.zip

Edited by nostradamus (see edit history)
  • Like 8

Share this post


Link to post
Share on other sites

Hi,

 

Im having a few problems. I have in BO 2 modules RSS Feed and RSS product feed, do i need to install 1 of them ?

 

How do i configure it. because when im in RSS Graffitit in add source "www.byxanthe.com/modules/feeder/rss.php" type it gives me an error Error: This Feed URL does not seem to be valid.

Share this post


Link to post
Share on other sites

Hi,

 

Im having a few problems. I have in BO 2 modules RSS Feed and RSS product feed, do i need to install 1 of them ?

 

How do i configure it. because when im in RSS Graffitit in add source "www.byxanthe.com/modules/feeder/rss.php" type it gives me an error Error: This Feed URL does not seem to be valid.

 

Sorry i forgot the module! You need to install RSS products feed to make it work.

Share this post


Link to post
Share on other sites

furthermore this line aint in my rss.php

$orderByValues = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position'); $orderWayValues = array(0 => 'ASC', 1 => 'DESC');

 

should i just add it??

Share this post


Link to post
Share on other sites

furthermore this line aint in my rss.php

$orderByValues = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position'); $orderWayValues = array(0 => 'ASC', 1 => 'DESC');

 

should i just add it??

 

Again my bad the find line was wrong. I changed it and i will add the modified feeder module to the first post as a download.

Share this post


Link to post
Share on other sites

ty, installed all. When i click on configure in the rss product feed module it says this:

 

Url for example:

http://www.byxanthe....hp?id_category={id_category}&orderby=position&orderway=asc

 

Replace {id_category} by the id category current or "0"

 

Is this correct ? Because there are no products uploaded to FB

Share this post


Link to post
Share on other sites

I have te 1.4.5.1 can i follow your instruction?

 

THANKS

 

you can give it a try make sure you make a backup of the feeder module

Share this post


Link to post
Share on other sites

you can give it a try make sure you make a backup of the feeder module

Ok i have tryed :) don't funct. I have modify files but the site was blocked, so i come back on my step.

Share this post


Link to post
Share on other sites

There is en error in your coding.

 

 

$products = Product::getNewProducts(intval($cookie->id_lang), 0, 10, false, 'date_add', 'DESC'

 

should be

$products = Product::getNewProducts(intval($cookie->id_lang), 0, 10, false, 'date_add', 'DESC');

Share this post


Link to post
Share on other sites

There is en error in your coding.

 

 

$products = Product::getNewProducts(intval($cookie->id_lang), 0, 10, false, 'date_add', 'DESC'

 

should be

$products =Product::getNewProducts(intval($cookie->id_lang),0,10,false,'date_add','DESC');

 

Thanks lost a bit in copy and past lol i fixed the first post

Share this post


Link to post
Share on other sites

I have 4 languages in my shop, will it be the default language in the FB posts then? I guess I need to change the default language if I want to post in another lang, right?

Share this post


Link to post
Share on other sites

Hi, you know a way to add the long description in the RSS Feed?

Share this post


Link to post
Share on other sites

hi...

$count = mt_rand(2,1133) ;
$id_category = ((int)(Tools::getValue('id_category')) ? (int)(Tools::getValue('id_category')) : $count);
$products = Product::getProducts((int)($cookie->id_lang), 0, 30, 'id_product', 'DESC', $id_category, true);

well... i have many categories and let the script choose random... but my problem is to skip empty categories...without products... how to do it? thanks

Share this post


Link to post
Share on other sites

Hey,

 

Worked on 1.4.8.2, trying to have it on 1.5.2 but it just open the save as for rss.php.

Did someone managed to make it work?

 

Thanks

Share this post


Link to post
Share on other sites

Now RSS Graffiti accept only RSS with W3C compatibility.....and Prestashop dont have RSS W3C compatible, anyone have a solution?

Share this post


Link to post
Share on other sites

I made all, that you have in tutorial, it saved without problems, but no feeds on facebook, when i want to see live preview RSS Grafiity said "There is currently no data for this feed." what can it be ?

Share this post


Link to post
Share on other sites

Now RSS Graffiti accept only W3C RSS certified and PS RSS is not compatible...

Share this post


Link to post
Share on other sites

rss.php

 

Hi there,

I modified the rss.php and now it seems to be accepted and goes through W3C validation.

This is working in PS 1.5.4.1.

You might want to toggle the following

 

$products = Product::getNewProducts(1, 0, 30);

1 is the language id, zero should not be changed and 30 is the number of products.

To get it validated I added

<description>My Desciption</description>

changed pubDate to

echo "\t\t\t<pubDate><![CDATA[".date("r",strtotime($product['date_add']))."]]></pubDate>\n";

addad guid

echo "\t\t\t<guid><![CDATA[".str_replace('&', '&', htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite((int)($product['id_category_default']), $cookie->id_lang)))).$affiliate."]]></guid>\n";

and to maybe get bigger previews I change

echo "<![CDATA[<img src='"._PS_BASE_URL_._THEME_PROD_DIR_.$imageObj->getExistingImgPath()."-thickbox_default.jpg' title='".str_replace('&', '', $product['name'])."' alt='thumb' />";

to thickbox.

Best regards, trip

  • Like 3

Share this post


Link to post
Share on other sites

RSS Graffiti dosent work for me i get this error

 

We were unable to find any publishable items in this feed. The feed may be empty, or the items in the feed may be missing critical elements (such as links or pubdates) which prevent us from publishing.

 

 

But the feed is ok

Share this post


Link to post
Share on other sites

Nice setting PS guy's,

I have download the files and wil go for it, when I have finished with my preview work to fix my shop to clean working.

 

Thanks for sharing this,

 

Generaal

Share this post


Link to post
Share on other sites

I got it working on 1.5.2, after following Trip's advice on post #34.

 

I decided to create a separate FB page for each of the 4 languages in my shop. And I created separate product feeds for each, too. Now for the Swedish language I need to force the currency to be SEK.

 

If I change line 36 in rss.php:

 

from

$currency = new Currency((int)Context::getContext()->currency->id);

 

to

$currency = new Currency(3);

 

it changes the currency symbol but doesn't convert the amount itself. How would I make it to force the prices in SEK?

Share this post


Link to post
Share on other sites

Hi All, ok i got to rss.php file and i don't have the first file that i am suppose to look for at the start of this tutorial...$orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby')); could someone lend me hand on what to do please....i'd like to have my new products show up on my facebook page.

 

thanks for the help. shop version 1.5.3

Share this post


Link to post
Share on other sites

Can noone help out on how to do this....or is there another way to get your products to post to facebook once you implement them to your site?

Share this post


Link to post
Share on other sites
I just saw that is published in English descriptions, etc ...

as I do to come out in Spanish??

Share this post


Link to post
Share on other sites

hello everyone!
I was able to make it work and the power of this is huge. Thank you for making it possible.

I was wondering why I only get the link of the products to be displayed on facebook and there is no product picture.

Sorry for my bad English. Am I the only one experiencing this? 

On the posts in my Facebook page I see only the product description with no product picture. 

Anyone know what's happening?

Thank you !!!

Share this post


Link to post
Share on other sites

I can't change the language description.Look the

<language> es</language> 

but the descriptions are in english

 

my rss linck

 

someone know why ???

Share this post


Link to post
Share on other sites

Hello !

 

This my code for rss.php on PS 1.5.6.2 :

<?php
/*
* 2007-2013 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 license@prestashop.com 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 <contact@prestashop.com>
*  @copyright  2007-2013 PrestaShop SA
*  @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);
$orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
$orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));
$id_category = ((int)(Tools::getValue('id_category')) ? (int)(Tools::getValue('id_category')) : Configuration::get('PS_HOME_CATEGORY'));

$products = Product::getNewProducts(1, 0, 30);

$currency = new Currency((int)Context::getContext()->currency->id);
$affiliate = (Tools::getValue('ac') ? '?ac='.(int)(Tools::getValue('ac')) : '');

// Send feed
header("Content-Type:text/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[<?php echo Configuration::get('PS_SHOP_NAME') ?>]]></title>
		<link><?php echo _PS_BASE_URL_.__PS_BASE_URI__; ?></link>
		<generator>PrestaShop</generator>
		<language><?php echo Context::getContext()->language->iso_code; ?></language>
		<description>My Desciption</description>
		<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>
        
        <atom:link href="<?php echo _PS_BASE_URL_.__PS_BASE_URI__.'modules/feeder/rss.php' ; ?>" rel="self" type="application/rss+xml" />
<?php
	foreach ($products AS $product)
	{
		$image = Image::getImages((int)($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<guid><![CDATA[".str_replace('&', '&', htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite((int)($product['id_category_default']), $cookie->id_lang)))).$affiliate."]]></guid>\n";
echo "\t\t\t<pubDate><![CDATA[".date("r",strtotime($product['date_add']))."]]></pubDate>\n";
		echo "\t\t\t<description>";
		
		$cdata = true;
		if (is_array($image) AND sizeof($image))
		{
			$imageObj = new Image($image[0]['id_image']);
			echo "<![CDATA[<img src='"._PS_BASE_URL_._THEME_PROD_DIR_.$imageObj->getExistingImgPath()."-thickbox_default.jpg' title='".str_replace('&', '', $product['name'])."' alt='thumb' />";
			$cdata = false;
		}
		if ($cdata)
			echo "<![CDATA[";
		echo $product['description_short']."]]></description>\n";

		echo "\t\t\t<link><![CDATA[".str_replace('&', '&', htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite((int)($product['id_category_default']), $cookie->id_lang)))).$affiliate."]]></link>\n";
		echo "\t\t</item>\n";
	}
?>
	</channel>
</rss>
I tried it with RSS Graffiti and it works
  • Like 1

Share this post


Link to post
Share on other sites

thanks...

I copy and past your code but the languish remains the same..!!

 

:-(

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More