Author Topic: Filter by published products in vm admin?  (Read 621 times)

sagaranvekar

  • Beginner
  • *
  • Posts: 40
Filter by published products in vm admin?
« on: August 22, 2019, 11:16:14 am »
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Filter by published products in vm admin?
« Reply #1 on: September 11, 2019, 14:52:51 pm »
You are right, it is just missing. Buy a bronze membership and I will add it https://extensions.virtuemart.net/support-updates/virtuemart-membership
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

cybersholt

  • Beginner
  • *
  • Posts: 4
Re: Filter by published products in vm admin?
« Reply #2 on: June 20, 2020, 20:58:59 pm »
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

Code: [Select]
$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

Code: [Select]
<?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

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 498
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Filter by published products in vm admin?
« Reply #3 on: June 20, 2020, 22:27:30 pm »
oops, this is ugly hack :)

Maybe is function, but right version will be as filter for manufacturer or category:

Code: [Select]
<?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 );?>
Code: [Select]
<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 from products, orders and database table
Virtuemart Email Manager - customs email templates