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

Filter by published products in vm admin?

Started by sagaranvekar, August 22, 2019, 11:16:14 AM

Previous topic - Next topic

sagaranvekar

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.

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

cybersholt

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'));
?>





pinochico

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...
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products