Hi david, I know it is possible to see all the product not mapped with unmapped.php but is it possible to see the unMapped product by feed?
Hi David,
This is a great mod, but unfortunately it's not compatible with this mod : http://www.pricetapestry.com/node/4050
Indeed, each product mapped with this mod still appears as "unmapped"
Do you think there is a solution to not display all the products mapped this way ?
Thanks
Bak
Hello Bak,
Sure - have a go with something like this:
<?php
header("Content-Type: text/plain");
require("includes/common.php");
$filename = (isset($_GET["filename"])?$_GET["filename"]:"");
$sql = "SELECT * FROM `".$config_databaseTablePrefix."categories`";
database_querySelect($sql,$rows);
$where = " name NOT IN (SELECT name FROM `".$config_databaseTablePrefix."productsmap`) ";
$ins = array();
foreach($rows as $category)
{
$alternates = explode("\n",$category["alternates"]);
foreach($alternates as $alternate)
{
$alternate = trim($alternate,"=");
$ins[] = "'".database_safe($alternate)."'";
}
}
if (count($ins))
{
$where .= " AND name NOT IN (".implode(",",$ins).") ";
}
$sql = "SELECT DISTINCT(name) FROM `".$config_databaseTablePrefix."products` WHERE ".$where;
if ($filename) $sql .= " AND filename='".database_safe($filename)."'";
$link = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword);
@mysql_select_db($config_databaseName,$link);
$result = mysql_unbuffered_query($sql,$link);
if ($result)
{
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
print $row["name"]."\n";
}
}
?>
Cheers,
David.
--
PriceTapestry.com
Thanks David, unfortunately it doesn't work :(
I tested with different products (both with simple and complicated names), and I always get the same list, i.e the complete list of names from the feed...
Bak
Hello Bak,
I just checked it out on my test server and everything looks OK as far as I can tell - please could you email me your unmapped.php and also includes/admin.php and I'll check all is consistent...
Cheers,
David.
--
PriceTapestry.com
Hi David,
I found the problem : I was using admin/unmapped.php, and calling unmapped.php.
Sorry for the inconveniance !
Thanks !
Bak
Hi David,
It seems that the script only exclude products mapped with their product name. Products already mapped with the Category Mapping are still appearing in the unmapped.php results
I made a test with a complete category, imported via the Category Mapping [239 products]
I checked the unmapped products, the 239 products are in the list.
I deleted/re created the category, and then cut/copy the 239 names to import them, using the node 4050. This time, my 239 products are not listed anymore in the unmapped product list.
And for sure, this time I'm using the right file ;)
Thanks DAvid
Hello Bak,
Would it be best to separate products that have triggered a Category Mapping from the export of products not mapped via Product Mapping?
I checked back to the last includes/admin.php that I have from you and I don't see the modification in place at that point; but assuming that you have added code for both exact match and keyword match (e.g. if product name contains "this" then set category to "that") then the following will export all products _not_ mapped in this way...
uncatmapped.php
<?php
header("Content-Type: text/plain");
require("includes/common.php");
$filename = (isset($_GET["filename"])?$_GET["filename"]:"");
$admin_importCategoryMappings = array();
$sql = "SELECT * FROM `".$config_databaseTablePrefix."categories`";
if (database_querySelect($sql,$rows))
{
foreach($rows as $category)
{
$alternates = explode("\n",$category["alternates"]);
foreach($alternates as $alternate)
{
$alternate = trim($alternate);
$admin_importCategoryMappings[$alternate] = $category["name"];
}
}
}
$link = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword);
@mysql_select_db($config_databaseName,$link);
$sql = "SELECT DISTINCT(name) FROM `".$config_databaseTablePrefix."products`";
if ($filename) $sql .= " AND filename='".database_safe($filename)."'";
$result = mysql_unbuffered_query($sql,$link);
if ($result)
{
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
$mapped = FALSE;
if (isset($admin_importCategoryMappings["=".$row["name"]]))
{
$mapped = TRUE;
}
else
{
foreach($admin_importCategoryMappings as $k => $v)
{
if (substr($k,0,1) !== "=")
{
$found = 0;
$words = explode(" ",$k);
foreach($words as $word)
{
if ($word)
{
if (strpos($row["name"],$word) !== FALSE) $found++;
}
}
if ($found == count($words))
{
$mapped = TRUE;
break;
}
}
}
}
if (!$mapped)
{
print $row["name"]."\n";
}
}
}
?>
(run from top level folder)
If still not exporting as expected, perhaps if you could email me your latest includes/admin.php i'll be able to tie the above exactly in with your current Category Mapping code...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hello Syn,
Sure - have a go with:
<?php
header("Content-Type: text/plain");
require("includes/common.php");
$filename = (isset($_GET["filename"])?$_GET["filename"]:"");
$sql = "SELECT DISTINCT(name) FROM `".$config_databaseTablePrefix."products` WHERE name NOT IN (SELECT name FROM `".$config_databaseTablePrefix."productsmap`)";
if ($filename) $sql .= " AND filename='".database_safe($filename)."'";
$link = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword);
@mysql_select_db($config_databaseName,$link);
$result = mysql_unbuffered_query($sql,$link);
if ($result)
{
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
print $row["name"]."\n";
}
}
?>
...and then request either as before;
unmapped.php
...for all unmapped products, or
unmapped.php?filename=Merchant.xml
...for unmapped products from the Merchant.xml feed.
Cheers,
David.
--
PriceTapestry.com