You are here:  » Niche Site - Multiple Product Colours


Niche Site - Multiple Product Colours

Submitted by crounauer on Mon, 2019-12-23 22:33 in

Hi David,

I have a niche site as you know and I'm looking to add multiple colours to advertise the fact that a specific product comes in more than 1 colour.

The only way I have thought about doing it is to add another table to the database and then add the additional colours along with links to the associated products

Database table as follows: -

id products_map_name colour

Am I on the right track or is there an easier way?

Thanks,
Simon

Submitted by support on Tue, 2019-12-24 09:34

Hi Simon,

If you don't mind setting up the colours on a per-product basis (probably just as easy as making a table and mapping single colours to multiple products + management etc., you could use the Meta Data feature of Product Mapping (essentially, like custom fields, but without any database modifications required...)

Cheers,
David.
--
PriceTapestry.com

Submitted by crounauer on Tue, 2019-12-24 11:47

Hi David,

Thanks for your reply - I didn't know about the meta data feature :)

So if I add a new field

$config_productMeta["colours"] = "Colours";

I then populate the field with colour "Red". What if the product has 4 other colours?

Thanks,
Simon

Submitted by support on Tue, 2019-12-24 12:02

You could use comma separated values

Red,Green,Blue

...and on your product pages (html/product.php) for example;

  <?php $colours tapestry_productMeta($product_main["name"],"colours"); ?>
  <?php if ($colours): ?>
    <p><strong>Available in:</strong> <?php print $colours?></p>
  <?php endif; ?>

Cheers,
David.
--
PriceTapestry.com

Submitted by crounauer on Tue, 2019-12-24 12:08

Thanks David,

So at the moment I have seperate listings for the same product but different colours as sometimes the prices vary depending on colour.

With that in mind I don't think the meta feature would be suitable as I wouldn't then be able to link to the various products from the colours

Is my thinking right?

Thanks,
Simon

Submitted by support on Fri, 2019-12-27 11:25

Hi Simon,

Would it be practical for you to (using filters etc.) set up a standard naming convention so that your products all contained the colour as the last word of the product name eg.

Widget Master Red
Widget Master Green
Widget Master Blue

If so, with a list of colours, it would be no problem to use the Related Products functionality to a) strip the colour from the product name of the product currently being viewed and b) use the base name as the SELECT query for Related Products (using a LIKE where clause) so that, in this example, if you were viewing "Widget Master Red", then Related Products would show "Widget Master Green" and "Widget Master Blue" to indicate the other colours available (and also show price from.. etc..)

What do you think?

Cheers,
David.
--
PriceTapestry.com

Submitted by crounauer on Mon, 2019-12-30 15:53

Hi David,

I think that could work and would also save me having to allocate all the alternative colours to each product.

Thank you!

Submitted by support on Tue, 2019-12-31 11:48

Hi,

To give this a go, edit products.php and look for the following code beginning at line 92:

      if ($product["products"][0]["category"])
      {
        $wheres[] = "category = '".database_safe($product["products"][0]["category"])."'";
        $ignoreFullText = TRUE;
      }
      if ($product["products"][0]["brand"])
      {
        $wheres[] = "brand = '".database_safe($product["products"][0]["brand"])."'";
        $ignoreFullText = TRUE;
      }

...and REPLACE with:

      $wheres[] = "name <> '".database_safe($product["products"][0]["name"])."'";
      $colours = array("Red","Green","Blue");
      $baseName = trim(str_replace($colours,"",$product["products"][0]["name"]));
      $wheres[] = "name LIKE '".database_safe($baseName)."%'";
      $ignoreFullText = TRUE;

Edit the colour list in the $colours array as required and that should do the trick...

Cheers,
David.
--
PriceTapestry.com