Hi,
Joomla 3.9.11 & VirtueMart 3.4.2
In VM admin, Products -> Products
There are filters for category, manufacturer etc but no filter for Published/Unpublished products.
Is there any way to add this filter? Is it something missed by VM team?
Please let me know if it is doable.
Thank you.
You are right, it is just missing. Buy a bronze membership and I will add it https://extensions.virtuemart.net/support-updates/virtuemart-membership
Since this is the first result in Google I figured I'd share a solution.
Tested only with Joomla 3.9.19 and Virtuemart 3.2.14.
administrator/components/com_virtuemart/models/product.php
Add around line 653 add after
$reqVar = vRequest::getInt('published','-1');
if($reqVar === '1') {
$where[] = ' p.`published`="1" ';
} else if($reqVar === '0') {
$where[] = ' p.`published`="0" ';
}
administrator/components/com_virtuemart/views/product/tmpl/default.php
Around line 34 After COM_VIRTUEMART_FILTER add after
<?php
$categories = array();
$categories[] = JHTML::_('select.option', '-1', JText::_("ALL"), 'id', 'title');
$categories[] = JHTML::_('select.option', '1', JText::_("PUBLISHED"), 'id', 'title');
$categories[] = JHTML::_('select.option', '0', JText::_("UNPUBLISHED"), 'id', 'title');
echo JHTML::_('select.genericlist', $categories, 'published', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'id', 'title', vRequest::getInt('published','-1'));
?>
oops, this is ugly hack :)
Maybe is function, but right version will be as filter for manufacturer or category:
<?php echo JHtml::_('select.genericlist', $this->manufacturers, 'virtuemart_manufacturer_id', 'class="inputbox" onchange="document.adminForm.submit(); return false;"', 'value', 'text', $this->model->virtuemart_manufacturer_id );?>
<select class="inputbox" id="virtuemart_category_id" name="virtuemart_category_id" onchange="this.form.submit(); return false;">
<option value=""><?php echo vmText::sprintf( 'COM_VIRTUEMART_SELECT' , vmText::_('COM_VIRTUEMART_CATEGORY')) ; ?></option>
</select>
And why array has name $categories ? The variable should not be renamed to $published or $this->published, isn't ? And define in another place...