News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Hide product rows in category based on virtuemart_product_id?

Started by mailblade, December 01, 2018, 15:47:07 PM

Previous topic - Next topic

mailblade

Hi!

I have three category layouts for my products.

One menu item (VirtueMart Category Layout via Menu item) is for "Dry", one menu item is for "Frozen" and one is "General", which shows all "Dry" and "Frozen" products combined.

Now, for the "General" menu item, I need to hide certain products depending on "virtuemart_product_id". You see, the problem is that I have some other products that are also displaying here, from a completely different category not related to either "Dry" or "Frozen". The "General" menu item should only list all products for "Dry" and "Frozen".

I added the product_id's which I want excluded from the view into an array and added it at the start of the "foreach" product output.

I have done the following, but it did not work:


<?php
// Start the Output
foreach ( $this->products as $product ) {
 
     
// Show the horizontal seperator
if ($iBrowseCol == && $iBrowseProduct $BrowseProducts_per_row) { ?>

<div class="horizontal-separator"></div>
<?php }

?>

<?php
$arr 
= [483,484,485,486,487,488,489,490,491];
if(!
in_array($virtuemart_product_id$arr)) { ?>

<tr style="border-bottom: 1px solid #ffb3b3; height: 30px;">
<td style="width: 45px;padding-right: 15px;"><?php 
// Get a db connection.
$db JFactory::getDbo();

// Create a new query object.
$query $db->getQuery(true);

// Select all records from the user profile table where key begins with "custom.".
// Order it by the ordering field.

$query->select($db->quoteName(array('customfield_value''virtuemart_product_id')));
$query->from($db->quoteName('jos_virtuemart_product_customfields'));
$query->where($db->quoteName('virtuemart_custom_id') . ' LIKE '$db->quote('6'). ' AND '$db->quoteName('virtuemart_product_id') . 'LIKE ' $db->quote($product->virtuemart_product_id));

// Reset the query using our newly populated query object.
$db->setQuery($query);

// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$results $db->loadResult();
echo (
$results); 
?>

</td>

<td style="padding-left: 10px;width: 300px; color: #ff3333;">
<?php 


 
echo $product->product_name
 
 
 
?>


</td>

<td style="width: 90px; text-align: center;">
<?php

// Get a db connection.
$db JFactory::getDbo();

// Create a new query object.
$query $db->getQuery(true);

// Select all records from the user profile table where key begins with "custom.".
// Order it by the ordering field.

$query->select($db->quoteName(array('customfield_value''virtuemart_product_id')));
$query->from($db->quoteName('jos_virtuemart_product_customfields'));
$query->where($db->quoteName('virtuemart_custom_id') . ' LIKE '$db->quote('3'). ' AND '$db->quoteName('virtuemart_product_id') . 'LIKE ' $db->quote($product->virtuemart_product_id));

// Reset the query using our newly populated query object.
$db->setQuery($query);

// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$results $db->loadResult();
echo (
$results); 
?>

</td>
</tr> <?php ?>


Obviously this is just a piece of the whole table, to show you what it looks like. I only added 3 fields from the table. 2 customfields and the product_name field.

Now, when I do this the rows for the products in the array are still showing. I have added the array at the start of the "foreach" output of the products, right after my table's headers.


GJC Web Design

Products can be in multiple VM cats  -- why don't u just put what u want in the appropriate cats and display the cat?
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

mailblade

But all the items already have a category. Either dry or frozen. I can't combine 2 categories

mailblade

I just created a parent category and added the other 2 categories as child to it.

Such an easy solution haha.