Add a new field can be a very time-consuming job in a project. You will have to not only add a new column but will also have to edit admin panel to manage that field, in price comparison will also have to edit code to import it from data feed as well as edit crawler to crawl information for that field.
WELL, it is very easy in price comparison script.
Read two examples below.
SIMPLE VALUE
Suppose you want to save the weight of each product in the database and display it on your website.
In our system, it is very easy to add these extra fields, like weight for the product.
Edit include/constants.php
At the bottom of the file, you will see several PHP defines (if they are not there, add them).
Your code will look like following:
Code: Select all
// Extra User Product Fields
define('PRODUCT_FIELD_1', 'Weight');
That is it what is needed. Now you can import this column using datafeeds, using manual update or even using crawler.
Once this field is populated with weight, you can edit template files to display this information there.
CALCULATED VALUE
Suppose you want to save TOTAL PRICE for a product in the PRICECOMPARISON_USER_PRODUCT table for each product. This TOTAL PRICE will be SALE PRICE + TAX.
The EASIEST option is the following:
Here I am sure you will be impressed.
1.
Edit include/constants.php
At the bottom of the file, you will see several PHP defines (if they are not there, add them). Just edit two as shown below.
Code: Select all
// Extra User Product Fields
define('USER_PRODUCT_FIELD_1', 'Total Price');
// Extra User Product Field Actions
define('USER_PRODUCT_FIELD_ACTION_1', 'calculateUserField1');
In include/include_site_user_product.php at the bottom of the file, there is a function defined calculateUserField1().
Replace line this
Code: Select all
return $userField1;
Code: Select all
return $price + $shipping;
NOW in MYSQL table PRICECOMPARISON_USER_PRODUCT, you will have a total price in the column name USER_FIELD_1. You can sort on it or do whatever you want.
You can do many things like above. It was just an example.