News:

Looking for documentation? Take a look on our wiki

Main Menu

Module to show one specific Product

Started by sprachrohr, March 01, 2017, 14:48:41 PM

Previous topic - Next topic

sprachrohr

Hi,

does anyone know a module to show only one specific product?

Thanks!
Best regards!

Edit by Mod: yes, here http://extensions.virtuemart.net/product/products/product-presenter-detail

jenkinhill

I use a special category when this is required. Make a new category - eg "Manager's Special"  and assign your single product to that category (products can be assigned to more than one category).

Then using the standard VirtueMart Products module, set that module to display a single random product, set the category filter to Yes and select that special category. Publish the module wherever you like.

Then if the featured product is to change, just remove the category from the current product and assigne to the new one.  This is simple enough for most store owners to be able to manage!
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

sprachrohr

Thanks for your answer!

Yes, this workaround should work. But my customer wants to show a lot of products that way. So he has to deal with many additional categories.

It would be very nice to select the product in the module.

Maybe someone else knows a module?

jenkinhill

There was a ,module for VM2 - http://forum.virtuemart.net/index.php?topic=99676.0  but I don't think there was much demand.

With my way you can choose to display several products in the module if you wish as long as they are all assigned to that category. Just configuration.   But it should not be too difficult to code a module to display a singe product based on product_id
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

sprachrohr

Thanks again,

yes you are right... if noone knows a module, i'll code it by myselfe.

When i follow your link, the page of the developer is dead.
But thanks for your help!


Studio 42

#5
Quote from: sprachrohr on March 01, 2017, 16:04:30 PM
Thanks again,

yes you are right... if noone knows a module, i'll code it by myselfe.

When i follow your link, the page of the developer is dead.
But thanks for your help!


CHeck mod_virtuemart_products you have the main code to do it.
You need an ID option to select the product
ANd replace
$products = $productModel->getProductListing($Product_group, $max_items, $show_price, true, false,$filter_category, $category_id);
with
$product = $productModel->getProduct ($id); or getProducts($ids), if you need multiple products
See https://shop.st42.fr/en/products/virtuemart-selected-product-s.htm i added it for free in my shop.

sprachrohr

thanks a lot!

I've coded it by myselfe.
best regards!

cihancomcom

I am trying to do the same. Please let me know how to code it.

sprachrohr

Quote from: cihancomcom on May 31, 2017, 10:35:52 AM
I am trying to do the same. Please let me know how to code it.

Hi,

what exactly do you want to know?

Did you read the post from studio 42? That is all you need.

cihancomcom

#9
I changed the code

$products = $productModel->getProductListing($Product_group, $max_items, $show_price, true, false,$filter_category, $category_id);
with
$product = $productModel->getProduct ($id);

It did not work?

Please let me know What I am doing wrong.

Thanks a lot.

sprachrohr

so first off all, you should not add these lines of code to mod_virtuemart_product. You should create a new/own module. In my case i created "mod_virtuemart_single_product".
If you add these lines of code and modify the core module, you will lose your changes in case of an virtuemart update.

Do you know how to do that? If not, maybe you shoud read some documentation first: https://docs.joomla.org/Portal:Developers/en#Modules

You also have to modify the xml-file to get an id option in your module configuration. In my case, this looks like this (you have to adust it to your needs!!!):

<field
   name="productId"
   type="sql"
   default="1"
   label="MOD_VIRTUEMART_SINGLE_PRODUCT_SELECT_A_PRODUCT"
   query="SELECT virtuemart_product_id, product_name FROM #__virtuemart_products_de_de"
   key_field="virtuemart_product_id"
       value_field="product_name"
   required="true"
      header="MOD_VIRTUEMART_SINGLE_PRODUCT_PLEASE_SELECT_A_PRODUCT"
/>

Now i have a dropdown to select the product. You could also use other form fileds like text maybe.

You can access it by:
$product_id = $params->get( 'productId', '1');

And then use it like this:
$product = $productModel->getProduct ($product_id);

Hope this helps. Im sorry that i cannot give you access to my module because of customers restrictions.

spammg

Your advice is very good and I had already implemented it, however I've got one question. How one can recall product photo to $product_id?

aftertaf

Anyone want to share their module? ;)
looking for same features but newbie PHP and I don't have the time to check it out...

Sent from my ASUS_Z017D using Tapatalk


Studio 42

I shared in my shop a module that i wrote for a customer.
Note that this have minimum options.
Can be downloaded here https://shop.st42.fr/en/products/virtuemart-selected-product-s.htm
You only have to fill product ID's separated by commas