Danh mục sản phẩm

Danh mục các hãng xe

Hỗ trợ khách hàng

 

Kinh doanh:

Tel: +84 4 39844705

-----------

SaleOnline:

Tel: +84 4 39844916

-----------

Kĩ thuật:

Tel: +84 4 39847471

-----------

Kế toán:

Tel:+84 4 22148644

-----------


Xem chi tiết...

Đối tác

logo

Cty-SHB

jenka-media

noithatoto-cartoyvn

Tìm kiếm sản phẩm: Giá từ: 100 đến 1 triệu   /  1 đến 2 triệu  /  2 đến 5 triệu  /  trên 5 triệu  /  trên 10 triệu
Trang chủ Tin tức VM - Virtuemart hacking Shop VirtueMart và các sản phẩm liên quan - VirtueMart and Related Products
Shop VirtueMart và các sản phẩm liên quan - VirtueMart and Related Products
Shop VirtueMart và các sản phẩm liên quan - VirtueMart and Related Products PDF. In Email

Related Product in VirtueMart is great but It can break the layout of your design. I am not talking about the module - you have full control over the module - I am talking about the  Related Proructs that display at the bottom of a product!


Its fixed to display 4 items in one row! So if your design's main-content area is narrow it could break and look like this:

You see the items expanded beyond the contents area and reached the sidebar on the right. I spent hours trying to figure where to control it from the administration panel without any success! I even downloaded the user manual but failed to find anything can fix it!

So, a new hack journy began Smile VirtueMart URLs helps you to understand where you should start :

index.php?page=shop.product_details&flypage=flypage.tpl

So, the code that control the layout of this page is located on:

administrator/components/com_virtuemart/html/shop.product_details.php

This line control how many items you would like to display:

1.$q .= "AND FIND_IN_SET(jos_{vm}_product.product_id,  REPLACE(related_products, '|', ',' )) LIMIT 0, 4";

It's set to 4. You can decrease the number to be 2 and the layout will be fixed! but thats not a practical solution! Says you want to display the 4 related products or even more!

There is another line display where exactly is the code for the Related Products part :

1.$related_products = $tpl->fetch( '/common/relatedProducts.tpl.php' );

You can find it on the template folder:

components/com_virtuemart/themes/default/templates/common/relatedProducts.tpl.php

01.<span class="content"><span class="block" style="margin-left: 0px ! important;">
02.
03.
04.
05.
06.
07.
08.
09.
10.
11.
12.<table style="width: 100%;" align="center">
13.<tbody>
14.<tr>
15.<td valign="top">product_snapshot( $products->f('product_sku') ) ?></td>
16.</tr>
17.</tbody>
18.</table>
19.</span></span>


The while loop create a for each new item. We need to modify this to end the row and start a new one when it reach the maximum value we specify. So, we set a new variable and call it $relatedproductcount and give it the number of maximum items per row. Using an if statement and an iterator we can edit the code to be like :

01.<table style="width: 100%;" align="center">
02.<tbody>
03.<tr>
04.</tr>
05.<tr>
06.<td valign="top">
07. product_snapshot( $products->f('product_sku') );
08. $relatedproductcount = 1;
09. } else {?>
10.</td>
11.<td valign="top">
12. product_snapshot( $products->f('product_sku') );
13. $relatedproductcount++; } ?>
14.</td>
15.</tr>
16.</tbody>
17.</table>

You can see the results here Smile

I don't really like modifying the core files and I belive what we did here is vital and should be controlled via the administration panel. I hope to see this in the future.

Note: I used VirtueMart version 1.1 I didnt test it on previous versions.

Thanks for reading!

Source: http://www.alfystudio.com/blog/47-virtuemart-and-related-products.html