문제

Where do I find the product class in osCommerce? I would like to modify the product class to suit my needs.

I checked the classes folder at includes/classes and found the shipping class, shopping cart class, etc. but couldn't find the product class.

These are the variables I would like to modify in the product class.

$products_price
$product_info['products_image']
$products_options
$products_options_name
$product_info

All these variables are used in pages that display products like oscommerce/product_info.php, oscommerce/product_review.php etc.

도움이 되었습니까?

해결책

There's no Product class in osccomerce.

in product_info.php all the variables are setted by a query in the product_info.php (line 75 more or less):

$product_info_query = tep_db_query("select p.products_id,
pd.products_name, pd.products_description, p.products_model, 
p.products_quantity, p.products_image, pd.products_url, 
p.products_price, p.products_tax_class_id,
p.products_date_added, p.products_date_available, 
p.manufacturers_id from " . TABLE_PRODUCTS . " p, "
 . TABLE_PRODUCTS_DESCRIPTION . " pd where 
p.products_status = '1' and p.products_id = '" . 
(int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id
 = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

$product_info = tep_db_fetch_array($product_info_query);

If you need to add something to a product, just add it to the products table in mysql and modify all the php is oscommerce where you want to use it.

For example: You need to add an ISBN field to all your products because you have an online library and you need it.

1.- Edit your products table to add the new field:

alter products ADD products_isbn VARCHAR(15);

2.- Go to all pages in catalog that shows products and you want to show the new field and edit the products sql

//products_info.php
$product_info_query = tep_db_query("select p.products_id,
pd.products_name, pd.products_description, p.products_model, 
p.products_quantity, p.products_image, pd.products_url, 
p.products_price, p.products_tax_class_id,
p.products_date_added, p.products_date_available, 
p.manufacturers_id,p.products_isbn from " . TABLE_PRODUCTS . " p, "
 . TABLE_PRODUCTS_DESCRIPTION . " pd where 
p.products_status = '1' and p.products_id = '" . 
(int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id
 = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

$product_info = tep_db_fetch_array($product_info_query);

(just before the from I have add p.products_isbn)

And now you have $products_info["products_isbn"] accessible to use it.

3.- if you want to add the fields into the products lists (categories view, search results, specials, upcoming products, newest products,...) you have to add it into the product listing catalog/includes/modules/product_listing.php (the most easy way to do it is track the products_name from catalog/index.php an dupe for the new field)

4.- if you want to show in a box (like "other clients also buy" or the right or left columns) you have to go to catalog/include/boxes/ and add it too.

5.- if you want to edit the new field in administration you have to edit catalog/admin/categories.php and add the new ( the easy way here is to track products_model and dupe for your new field)

I'm sure I'm leaving more changes, because these are the minimal changes for showing the new field, if the new field has any functionality like discounts you have to edit the order class, the checkout process,....

Yes, it's a mess

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top