Mình đang làm hiển thị lượt xem sản phẩm virtunemart. Có hướng dấn thêm field vào jos_vm_product mình tìm thấy jos đó nhưng không biết làm sao thêm vào. Mình mở dạng php nhưng toàn bị mã hóa Mong mấy bạn giúp mình. Cảm ơn mấy bạn nhiều.
Đầu tiên các bạn mở phpmyadmin lên sau đó tìm bảng jos_vm_product và thêm vào đó 1 field thông qua câu lệnh PHP Code: ALTER TABLE `jos_vm_product` ADD `product` INT( 11 ) NOT NULL Làm sao thêm câu lệnh vô phần jos đó bạn.
Out of box, VirtueMart products have many “fields”, product name, sku, price, etc. If you need an additional field or two for your own business needs, you can do that by changing data model as well as some php code. It’s a bit of work … hope this post can help save you some time and effort. Modify Data Model First, data model needs to be modified to add the column. If you used the default prefix, the sql command will be something like: Mã: alter table jos_vm_product add ( nc_product_new_field varchar(200) null ); It’s best to name the new field with your own fix so down the road you can easily remember that it’s your field, not what comes with VirtueMart. Admin Interface File: /administrator/components/com_virtuemart/html/product.product_form.php This is where the product add/edit form is coded. Find a place for your new field, and add the form input. HTML: <tr> <td> <div style="text-align:right;font-weight:bold;"> My Publication Date: (yyyy-mm-dd) </div> </td> <td width="79%"> <input type="text" class="inputbox" name="my_publication_date" value="<?php $db->sp("my_publication_date"); ?>" size="32" maxlength="255" /> </td> </tr> Product Class Most files of VirtueMart component is defined in the administrator section. In file/administrator/components/com_virtuemart/classes/ps_product.php Modify two functions: add() and update(). Make sure the new field is included in the SQL statement. At this point, you can add new product with this additional field and also modify the new field using VirtueMart administrator interface. Now, you will need to modify the front-end product details page to display the new field. Product Details Page There are two files you need to change. One is the template page. (Again, this file is in the administrator section.) In file/administrator/components/com_virtuemart/html/templates/product_details/flypage.php, you add the new field display. For example, {my_publication_date}. Also you need to change file:/administrator/components/com_virtuemart/html/shop.product_details.php. You will set the value for the new field here. Mã: $template = str_replace( "{my_publication_date}", $db_product->f("my_publication_date"), $template ); What Else? If you like to display the new field in the browse page, etc. just find the right template as well as the corresponding php page to pull out value for the template. Cái này sưu tầm trên mạng về. Chưa có thời gian test. Các bạn test rồi báo cáo nhé
Có thể làm dễ hiểu hơn không bạn. Bây giờ trong mục database mình nó có phần tên: jos_vm_product và mình mở lên thì không thấy chỗ nào để add code php như sau: ALTER TABLE `jos_vm_product` ADD `product` INT( 11 ) NOT NULL vào. Bạn có thể cho mình cái nguồn để truy xuất vào và add đoạn code đó vô được không, thanks bạn rất nhiều.