You are here:  » only add master.csv product into sitemap


only add master.csv product into sitemap

Submitted by technoarenasol on Sun, 2012-10-28 09:48 in

Hi David

1)I want to add only master.csv file product into sitemap for better SEO ... can be possible ?

2)other thing is display "product not available" in price comparison table If product not available on any merchant

Thanks
Amin

Submitted by support on Mon, 2012-10-29 09:22

Hello Amin,

The easiest thing to do would actually be to build your sitemap directly from master.csv instead of the database! Have a go with this:

<?php
  set_time_limit
(0);
  require_once(
"../includes/common.php");
  require_once(
"../includes/MagicParser.php");
  
header("Content-Type: text/xml");
  print 
"<"."?xml version='1.0' encoding='UTF-8'?".">";
  print 
"<urlset xmlns='http://www.google.com/schemas/sitemap/0.84' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd'>";
  
$sitemapBaseHREF "http://".$_SERVER["HTTP_HOST"].$config_baseHREF;
  function 
myRecordHandler($record)
  {
    global 
$sitemapBaseHREF;
    global 
$config_useRewrite;
    if (
$config_useRewrite)
    {
      
$sitemapHREF "product/".urlencode(str_replace(" ","-",tapestry_normalise($record["name"]))).".html";
    }
    else
    {
      
$sitemapHREF "products.php?q=".urlencode(tapestry_normalise($record["name"]));
    }
    print 
"<url>";
    print 
"<loc>".$sitemapBaseHREF.$sitemapHREF."</loc>";
    print 
"</url>";
  }
  
MagicParser_parse($config_feedDirectory."master.csv","myRecordHandler","csv|44|1|34");
  print 
"</urlset>";
?>

Regarding the price comparison table showing not available merchants, look for the closing </table> towards the end of your html/prices.php (line 19 in the distribution)

  </table>

....and REPLACE with:

  <?php
    $ins = array();
    foreach($prices["products"] as $product)
    {
      $ins[] = "'".database_safe($product["merchant"])."'";
    }
    $sql = "SELECT DISTINCT(merchant) FROM `".$config_databaseTablePrefix."products` WHERE merchant NOT IN (".implode(",",$ins).")";
    if (database_querySelect($sql,$products))
    {
      foreach($products as $product)
      {
        if ($config_useRewrite)
        {
          $product["merchantHREF"] = $config_baseHREF."merchant/".urlencode(tapestry_hyphenate($product["merchant"]))."/";
        }
        else
        {
          $product["merchantHREF"] = $config_baseHREF."search.php?q=merchant:".urlencode($product["merchant"]).":";
        }
        ?>
        <td><a href='<?php print $product["merchantHREF"]; ?>'><?php print (file_exists("logos/".$product["merchant"])?"<img src='".$config_baseHREF."logos/".$product["merchant"]."' border='0' />":$product["merchant"]); ?></a></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>Not Stocked</td>
        <?php
      }
    }
  ?>
  </table>

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Tue, 2012-10-30 10:43

Hi David

error on sitemap.php page

This page contains the following errors:

error on line 1 at column 158: Opening and ending tag mismatch: urlset line 0 and url
Below is a rendering of the page up to the first error

Submitted by support on Tue, 2012-10-30 11:10

Hi,

I'll follow up by email as it's related to the filter sort modification that I sent earlier (duplication of function name...)

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Tue, 2012-10-30 12:16

technoarenasol

Hi David

I update sidebar and sitemap file which you send me on email but same error display

Submitted by support on Tue, 2012-10-30 12:26

Hi,

Opening <url> was missing - corrected in the above...

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Tue, 2012-10-30 12:48

technoarenasol

Thnx David..Now working

Submitted by technoarenasol on Sun, 2012-11-11 11:17

technoarenasol

Hi David

I add more than 2000 product in master.csv but in sitemap.php only comes 845 products..

link : {link saved}

Thanks
Amin

Submitted by technoarenasol on Mon, 2012-11-12 10:45

technoarenasol

Plz tell me if product added into master file and not available in any merchant feed so that product link submitted google webmaster(means that product link available in stemap.php ?)

Thanks
Amin

Submitted by support on Mon, 2012-11-12 10:59

Hi Amin,

I fetched your sitemap to my test server and contains 844 <loc> elements. Note that your GWT account reports the total URLs submitted (in the sitemap) but also total indexed separately which may be the number you are seeing. Let me know if you're still not sure of course;

About your last question - yes, as it stands if there is a product in your master.csv that is not on your site then yes there will be a sitemap entry for it. This can be fixed easily. In your custom (mobile/sitemap.php) script, where you have a line 12:

    global $config_useRewrite;

...REPLACE with:

    global $config_useRewrite;
    global $config_databaseTablePrefix;
    $sql = "SELECT id FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($record["name"])."' LIMIT 1";
    if (!database_querySelect($sql,$result)) return;

That will then limit sitemap entries to live products...

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Wed, 2012-11-14 08:04

Hi David

from last day no product name list display in sitemap..I am not changes in sitemap.php

<?php
  set_time_limit(0);
  require_once("../includes/common.php");
  require_once("../includes/MagicParser.php");
  header("Content-Type: text/xml");
  print "<"."?xml version='1.0' encoding='UTF-8'?".">";
  print "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd'>";
  $sitemapBaseHREF = "http://".$_SERVER["HTTP_HOST"].$config_baseHREF;
  function myRecordHandler($record)
  {
    global $sitemapBaseHREF;
    global $config_useRewrite;
    if ($config_useRewrite)
    {
      $sitemapHREF = "product/".urlencode(str_replace(" ","-",tapestry_normalise($record["name"]))).".html";
    }
    else
    {
      $sitemapHREF = "products.php?q=".urlencode(tapestry_normalise($record["name"]));
    }
    print "<url>";
    print "<loc>".$sitemapBaseHREF.$sitemapHREF."</loc>";
    print "</url>";
  }
  MagicParser_parse($config_feedDirectory."master.csv","myRecordHandler","csv|44|1|34");
  print "</urlset>";
?>

Submitted by support on Wed, 2012-11-14 09:32

Hi Amin,

I see it is empty on your site at

/mobile/sitemap.php

...if you need the script to run from there but there is no longer a Price Tapestry installation at the top level, change these 2 lines:

  require_once("../includes/common.php");
  require_once("../includes/MagicParser.php");

to:

  require_once("includes/common.php");
  require_once("includes/MagicParser.php");

That should be all it is!

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Wed, 2012-11-14 10:16

technoarenasol

Hi David

No change after applying above changes .

{link saved}

Thanks
Amin

Submitted by support on Wed, 2012-11-14 10:55

Hi Amin,

Ah - final change in order to run from /mobile/, REPLACE this line:

   MagicParser_parse($config_feedDirectory."master.csv","myRecordHandler","csv|44|1|34");

with:

   MagicParser_parse("feeds/master.csv","myRecordHandler","csv|44|1|34");

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Fri, 2012-11-16 09:30

technoarenasol

Hi David,

Above code is use for price comparison table showing not available merchants.
but actually I want if any merchant not available than display "product not available in any seller"

example :
If nokia asha 302 available on 2 seller than only display 2 seller details (don't want to display all seller details )

If Nokia asha 305 not available on any seller than display "product not available in any seller" (remove price comparison table )


and also "not available" product not comes to search results page

Thanx
amin

Submitted by support on Fri, 2012-11-16 11:20

Hello Amin,

If there are no merchant prices the product is not in the database so there is no product page for it - the request to an old product page would return 404 but also display Related Products to help the visitor find an alternative product.

However, what you could do is rather than send the 404, instead parse your master.csv file and display the description etc. from that. In your products.php look for and delete or comment out the following code at line 124:

      header("HTTP/1.0 404 Not Found");
      $banner["h2"] .= "(".translate("product not found").")";

And then at your line 163:

  if (isset($product)) require("html/product1.php");

...replace with:

  if (isset($product))
  {
    require("html/product1.php");
  }
  else
  {
     require("html/product_notfound.php");
  }

Then need to make a new file html/product_notfound.php containing something like this:

<?php
  require("includes/MagicParser.php");
  function myRecordHandler($record)
  {
    if ($record["name"]==$_GET["q"])
    {
?>
<!-- edit this section here to make output look same as normal product page -->
<h1><?php print $record["name"]; ?></h1>
<img src='<?php print $record["image_url"]; ?>' />
<p><?php print $record["description"]; ?></p>
<p><strong>Product not available in any seller.</strong></p>
<?php
      return TRUE;
    }
  }
  MagicParser_parse("feeds/master.csv","myRecordHandler","csv|44|1|0");
?>

Of course you can change the HTML section of the above code to make the output look identical to the normal product page output generated by your html/product1.php.

Hope this points you in the right direction!

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Fri, 2012-11-16 12:14

technoarenasol

Hi David ....Nice..its working ....but when any one type wrong product URL than how to display 404 error page ??

Submitted by support on Fri, 2012-11-16 12:48

Hi Amin,

You need to find out not that it is not found before header goes out; so back to first instruction where to look for this code at line 124 in your products.php

      header("HTTP/1.0 404 Not Found");
      $banner["h2"] .= "(".translate("product not found").")";

...instead REPLACE this with:

  $nomerchantsHTML = "";
  require("includes/MagicParser.php");
  function myRecordHandler($record)
  {
    if ($record["name"]==$_GET["q"])
    {
$nomerchantsHTML = "
<h1>".$record["name"]."</h1>
<img src='".$record["image_url"]."' />
<p>".$record["description"]."</p>
<p><strong>Product not available in any seller.</strong></p>
";
      return TRUE;
    }
  }
  MagicParser_parse("feeds/master.csv","myRecordHandler","csv|44|1|0");
  if (!$nomerchantsHTML)
  {
    header("HTTP/1.0 404 Not Found");
    $banner["h2"] .= "(".translate("product not found").")";
  }

This time the HTML is in a PHP string but again you can edit the HTML to make it look exactly as your normal product page if required.

Then, where you now have:

  if (isset($product))
  {
    require("html/product1.php");
  }
  else
  {
    require("html/product_notfound.php");
  }

...REPLACE with:

  if (isset($product))
  {
    require("html/product1.php");
  }
  else
  {
    if ($nomerchantsHTML)
    {
      print $nomerchantsHTML;
    }
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Fri, 2012-11-16 13:09

technoarenasol

Hi David..can be possible to call noproduct file because my "no product available " page code very large

like this

  $nomerchantsHTML = "";
  require("includes/MagicParser.php");
  function myRecordHandler($record)
  {
    if ($record["name"]==$_GET["q"])
    {
      $nomerchantsHTML = require("html/noproductfound.php");
      return TRUE;
    }
  }
  MagicParser_parse("feeds/master.csv","myRecordHandler","csv|44|1|0");
  if (!$nomerchantsHTML)
  {
    header("HTTP/1.0 404 Not Found");
    $banner["h2"] .= "(".translate("product not found").")";
  }

Submitted by support on Fri, 2012-11-16 13:33

Hello Amin,

Yes - best way is to put $record into a global variable, then use it in html/noproductfound.php, so main code from above:

  $nomerchantsRecord = "";
  require("includes/MagicParser.php");
  function myRecordHandler($record)
  {
    global $nomerchantsRecord;
    if ($record["name"]==$_GET["q"])
    {
      $nomerchantsRecord = $record;
      return TRUE;
    }
  }
  MagicParser_parse("feeds/master.csv","myRecordHandler","csv|44|1|0");
  if (!is_array($nomerchantsRecord))
  {
    header("HTTP/1.0 404 Not Found");
    $banner["h2"] .= "(".translate("product not found").")";
  }

Then at the end:

  if (isset($product))
  {
    require("html/product1.php");
  }
  else
  {
    if (is_array($nomerchantsRecord))
    {
      require("html/noproductfound.php");
    }
  }

And in html/noproductfound.php, wherever you want to display variables from the master record use $nomerchantsRecord["field"] e.g.

<h1><?php print $nomerchantsRecord["name"]; ?></h1>
<img src='<?php print $nomerchantsRecord["image_url"]; ?>' />
<p><?php print $nomerchantsRecord["description"]; ?></p>
<p><strong>Product not available in any seller.</strong></p>

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Sat, 2012-11-17 09:26

technoarenasol

Hi David,

I added line require("html/404.php"); for display error 404 page If anyone Type Wrong URL

  $nomerchantsRecord = "";
  require("includes/MagicParser.php");
  function myRecordHandler($record)
  {
    global $nomerchantsRecord;
    if ($record["name"]==$_GET["q"])
    {
      $nomerchantsRecord = $record;
      return TRUE;
    }
  }
  MagicParser_parse("feeds/master.csv","myRecordHandler","csv|44|1|0");
  if (!is_array($nomerchantsRecord))
  {
    header("HTTP/1.0 404 Not Found");
    require("html/404.php");
    exit();
    $banner["h2"] .= "(".translate("product not found").")";
  }

I think you not understand my point clearly .so here I give clear view

1)If any one type wrong URL than comes 404 error page
2)If no seller available in particular product than display no seller available(replace of price comparison table)..Because many time product link available in google search but that time that product not available in any seller so broken link consider.... so Its not good for user ....so Dont want to broken that link

Thanks
Amin

Submitted by support on Sun, 2012-11-18 10:28

Hi Amin,

Your code looks fine, although this line is redundant now:

    $banner["h2"] .= "(".translate("product not found").")";

(since it immediately follows an exit() statement)

So it should behave as you describe - completely not found is 404 (and your html/404.php page), otherwise $nomerchantRecord will be set, and you can display your product information followed by the "Product not available in any seller." message. Let me know if you're still not sure...

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Sun, 2012-11-18 11:05

technoarenasol

Hi David

Not working "product not found " code..In all URL comes 404 error page .

Submitted by support on Sun, 2012-11-18 15:53

Hi Amin,

The comparison should probably be made against $q instead - have a go with:

  $nomerchantsRecord = "";
  require("includes/MagicParser.php");
  function myRecordHandler($record)
  {
    global $nomerchantsRecord;
    global $q;
    if (tapestry_normalise($record["name"],":\.")==$q)
    {
      $nomerchantsRecord = $record;
      return TRUE;
    }
  }
  MagicParser_parse("feeds/master.csv","myRecordHandler","csv|44|1|0");
  if (!is_array($nomerchantsRecord))
  {
    header("HTTP/1.0 404 Not Found");
    require("html/404.php");
    exit();
    $banner["h2"] .= "(".translate("product not found").")";
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Sun, 2012-11-18 16:26

Hi David,

Not working David..Check this page {link saved}

Thanks
Amin

Submitted by support on Sun, 2012-11-18 16:31

Hi Amin,

Ah I'd forgotten that you were using all lower case in your URLs - in place of this line in the modification:

  if (tapestry_normalise($record["name"],":\.")==$q)

...use:

  if (tapestry_normalise(strtolower($record["name"]),":\.")==$q)

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Sun, 2012-11-18 17:40

technoarenasol

Hi David...works now ...Thanx a lot :)

Submitted by technoarenasol on Wed, 2012-11-28 10:45

technoarenasol

Hi David can be possible to add related product function in noproductfound.php same as product1.php

Thanks you

Submitted by support on Wed, 2012-11-28 10:56

Hello Amin,

Sure you can - it looks like the related products SELECT SQL will have been executed in your modified products.php so it's just case of adding the display code to noproductfound.php. If you product1.php contains a call as follows:

  if (isset($related)) require("html/related.php");

...simply copy exactly the same code into noproductfound.php; otherwise implement in the same way. If you're not sure; let me know how Related Products are included in your product1.php and I'll check it out...

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Wed, 2012-11-28 11:17

technoarenasol

Thnx David..its working..

But one problem in noproductfound page ...its takes long time ..I think its match product name with master csv file...so check complete master file for matching name..any solution for improve loading time of noproductpage file ??

Thnx
Amin

Submitted by support on Wed, 2012-11-28 13:28

Hello Amin,

Magic Parser by default supports multi-line quoted text fields (at the slight expense of parsing speed) however since that will not be required in your script you could use a version that I have that does not include this support and will be faster - I'll email that to you now to try...

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Wed, 2012-11-28 14:14

technoarenasol

Thnx David...trick work....

Submitted by technoarenasol on Wed, 2012-11-28 14:20

Hi David,

Plz tell me When MagicParser need ??...In Which Function magicparser used ??

Thnx

Amin

Submitted by support on Wed, 2012-11-28 14:29

Hi Amin,

It's the library function that reads your master.csv feed (in the case of your custom sitemap and noproductfound.php page) - in the main script it parses each feed during import...

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Wed, 2012-11-28 14:49

Thnx David

Submitted by technoarenasol on Wed, 2012-11-28 17:24

Hi David

can you tell me difference between csv|44|1|0 and csv|44|1|34 .In one place you give me csv|44|1|0 code and other place give me csv|44|1|34 code

I ask you because In nopagefound I got wrong value from master.csv file .....Its separate value if any field contain ","character

Exmaple One field value is :
"Android,4.0"

So get "Android" value in current field and "4.0" go to next field.

Thanx
Amin

Submitted by support on Wed, 2012-11-28 21:13

Hello Amin,

Ah - in that case you want to use csv|44|1|34 wherever you are using MagicParser_parse() with master.csv - the 34 means quotes as the text delimiter (34 is the ASCII code for ") so using csv|44|1|34 your example field will then appear correctly.

Cheers,
David.
--
PriceTapestry.com

Submitted by technoarenasol on Wed, 2013-01-02 17:16

Hi David

One problem is looking up record in master file when no merchant available. Problem related to dot character (.)

its not generate without dot URL from master product name.... suppose one master file product name is "Nokia Mobile 5.0" Its create URL For product is like "www.example.com/mobile/nokia-mobile-5.0 " how to change URL without DOT when product not available in any merchant

Thanks
Amin

Submitted by support on Thu, 2013-01-03 10:31

Hi Amin,

URLs are based on the normalised_name field in the database; I notice that my code above suggest permitting "." by way of the allowed characters parameter in the call to tapestry_normalise()

  if (tapestry_normalise(strtolower($record["name"]),":\.")==$q)

...if that's relevant to this issue REPLACE that with:

  if (tapestry_normalise(strtolower($record["name"]))==$q)

Otherwise, wherever you are processing the name field from master.csv, using

tapestry_hyphenate(tapestry_normalise($record["name"]))

...will give the name exactly as it appears in URLs...

Cheers,
David.
--
PriceTapestry.com