Hello David
I'm wondering if they would be a way of creating our own categories on the website and then entering the product name we would like to appear in that category.
I understand category mapping only lets you import other category names.
Thanks
Mally
Hello David
I tried doing this for Rugby Magazines and it seems to work well.
Only thing is, is this magazine Champions Magazine which seems to be about football.
I've not added it to the category list for rugby magazines but so it must be in one of the category mapping selections to appear there.
Is there a way to add some code to a product.php to see what category its in (this could be code added and then commented out if not wanted generally.
Should I just add the code above to list the magazine in the Football Magazines category which should overule mapping categories and remove it from the rugby cat?
Hi Mally,
Yes - the code above will override any other place the category could be set (field or fixed value). To show the current category of a product, you could add the following right at the bottom of html/product.php
<?php
print "<p>Category: ".$mainProduct["category"]."</p>";
?>
Cheers,
David.
Hello David
Is it possible to have one product in more than one category?
For example I have a product called Your Dog Magazine but I would like it to appear in both Dog Magazines and Pet Magazines
Thanks Mally
Hi Mally,
It's a straight forward mod to make search.php (which generates the category pages) include another category when the category is a specific value. To do this, make sure the magazine has the most exclusive category name - in this case "Dog Magazines".
Then look for the following code around line 42:
case "merchant":
// pass through to category
case "category":
// pass through to brand
case "brand":
$where = " ".$parts[0]."='".database_safe($parts[1])."' ";
...and ADD the following new code immediately afterwards:
if ($parts[0] == "category")
{
$subcats["Pet Magazines"] = array("Dog Magazines","Cat Magazines");
$subcats["Sport Magazines"] = array("Football Magazines","Golf Magazines","Tennis Magazines");
if (is_array($subcats[$parts[1]]))
{
foreach($subcats[$parts[1]] as $subcat)
{
$where .=" OR category='".database_safe($subcat)."' ";
}
}
}
Hope this helps!
Cheers,
David.
Hi Mally,
On the basis that any one product can only be in one category, it would be an easy hack into the import record handler function to implement this. You'll find the current category code beginning at line 208 of includes/admin.php with the following comment:
/* construct category value if required */
(although I know that your admin.php has been modified, so it's probably easiest just to search for that comment).
Anyway, after that block, which sets the category value into the $category variable, you could add this code:
$categories["Product 1"] = "Some Category";
$categories["Product 2"] = "Some Category";
$categories["Product 3"] = "Some Other Category";
$categories["Product 4"] = "Some Other Category Again";
// etc. etc.
if ($categories[$record[$admin_importFeed["field_name"]]])
$category = $categories[$record[$admin_importFeed["field_name"]]];
Cheers,
David.