Skip to content
Snippets Groups Projects
Commit 7a7b6a77 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Version 1.1: Fix category loading (use sql rather than the model, which only returns 15 categories)

parent 93d261f1
No related branches found
No related tags found
No related merge requests found
*~ *~
BASE=vmAutoParentCategories BASE=vmAutoParentCategories
PLUGINTYPE=system PLUGINTYPE=system
VERSION=1.0 VERSION=1.1
PLUGINFILES=$(BASE).php $(BASE).xml index.html PLUGINFILES=$(BASE).php $(BASE).xml index.html
# TRANSDIR=../../../administrator/language/ # TRANSDIR=../../../administrator/language/
......
...@@ -8,8 +8,9 @@ VMAUTOCATEGORIES_DESCRIPTION="<h2>Virtuemart 2 automatische Produktkategorien Pl ...@@ -8,8 +8,9 @@ VMAUTOCATEGORIES_DESCRIPTION="<h2>Virtuemart 2 automatische Produktkategorien Pl
VMAUTOCATEGORIES_RUN="Führe Plugin aus:" VMAUTOCATEGORIES_RUN="Führe Plugin aus:"
VMAUTOCATEGORIES_RUN_DESC="Wählen Sie aus, wann das Plugin ausgeführt wird und die Kategorien der VirtueMart Produkte modifiziert." VMAUTOCATEGORIES_RUN_DESC="Wählen Sie aus, wann das Plugin ausgeführt wird und die Kategorien der VirtueMart Produkte modifiziert."
VMAUTOCATEGORIES_RUN_NEVER="Nie" VMAUTOCATEGORIES_RUN_NEVER="Nie (nur manuell)"
VMAUTOCATEGORIES_RUN_BACKEND_LOGIN="Joomla Backend Login" VMAUTOCATEGORIES_RUN_BACKEND_LOGIN="Joomla Backend Administrator Login"
VMAUTOCATEGORIES_RUN_FRONTEND_LOGIN="Joomla Frontend Administrator Login"
VMAUTOCATEGORIES_RUN_VM_STARTPAGE="VirtueMart Startseite (Backend)" VMAUTOCATEGORIES_RUN_VM_STARTPAGE="VirtueMart Startseite (Backend)"
VMAUTOCATEGORIES_RUN_VM_PRODUCTPAGE="VirtueMart Produktliste (Backend)" VMAUTOCATEGORIES_RUN_VM_PRODUCTPAGE="VirtueMart Produktliste (Backend)"
......
...@@ -8,8 +8,9 @@ VMAUTOCATEGORIES_DESCRIPTION="<h2>Virtuemart 2 Auto Product Categories plugin</h ...@@ -8,8 +8,9 @@ VMAUTOCATEGORIES_DESCRIPTION="<h2>Virtuemart 2 Auto Product Categories plugin</h
VMAUTOCATEGORIES_RUN="Run plugin on:" VMAUTOCATEGORIES_RUN="Run plugin on:"
VMAUTOCATEGORIES_RUN_DESC="Select when the plugin shall be run and automatically modify the VirtueMart categories of your products." VMAUTOCATEGORIES_RUN_DESC="Select when the plugin shall be run and automatically modify the VirtueMart categories of your products."
VMAUTOCATEGORIES_RUN_NEVER="Never" VMAUTOCATEGORIES_RUN_NEVER="Never (only manual)"
VMAUTOCATEGORIES_RUN_BACKEND_LOGIN="Joomla Backend login" VMAUTOCATEGORIES_RUN_BACKEND_LOGIN="Joomla Backend Administrator Login"
VMAUTOCATEGORIES_RUN_FRONTEND_LOGIN="Joomla Frontend Administrator Login"
VMAUTOCATEGORIES_RUN_VM_STARTPAGE="VirtueMart start page (Backend)" VMAUTOCATEGORIES_RUN_VM_STARTPAGE="VirtueMart start page (Backend)"
VMAUTOCATEGORIES_RUN_VM_PRODUCTPAGE="VirtueMart product list page (Backend)" VMAUTOCATEGORIES_RUN_VM_PRODUCTPAGE="VirtueMart product list page (Backend)"
......
File added
<?php <?php
/** /**
* @plugin VMAutoParentCategories * @plugin VMAutoParentCategories
* Version 1.0, 2012-12-18 * Version 1.1, 2013-02-24
* @copyright Copyright (C) 2012 Reinhold Kainhofer - All rights reserved. * @copyright Copyright (C) 2012-2013 Reinhold Kainhofer - All rights reserved.
* @Website : http://www.kainhofer.com * @Website : http://www.kainhofer.com
* @license - http://www.gnu.org/licenses/gpl.html GNU/GPL * @license - http://www.gnu.org/licenses/gpl.html GNU/GPL
**/ **/
...@@ -17,6 +17,15 @@ class plgSystemVMAutoParentCategories extends JPlugin { ...@@ -17,6 +17,15 @@ class plgSystemVMAutoParentCategories extends JPlugin {
var $_report = TRUE; var $_report = TRUE;
var $_debug = FALSE; var $_debug = FALSE;
function onAfterRoute(){
/** Alternatively you may use chaining */
if(!JFactory::getApplication()->isAdmin()) return;
if ($this->checkForRoutingTrigger()) {
$this->initSettings();
$this->updateCategories();
}
}
function initSettings() { function initSettings() {
$this->_dbg = $this->params->get('debug','report_changes'); $this->_dbg = $this->params->get('debug','report_changes');
...@@ -43,7 +52,7 @@ class plgSystemVMAutoParentCategories extends JPlugin { ...@@ -43,7 +52,7 @@ class plgSystemVMAutoParentCategories extends JPlugin {
break; break;
} }
} }
function checkForTrigger() { function checkForRoutingTrigger() {
$trigger = $this->params->get('run_trigger', 'never'); $trigger = $this->params->get('run_trigger', 'never');
// Explicit call will ALWAYS trigger // Explicit call will ALWAYS trigger
if (JRequest::getCmd('vmAutoParentCategories') == 'run') { if (JRequest::getCmd('vmAutoParentCategories') == 'run') {
...@@ -66,25 +75,15 @@ class plgSystemVMAutoParentCategories extends JPlugin { ...@@ -66,25 +75,15 @@ class plgSystemVMAutoParentCategories extends JPlugin {
} }
return $run; return $run;
} }
function onAfterRoute(){
/** Alternatively you may use chaining */
if(!JFactory::getApplication()->isAdmin()) return;
if ($this->checkForTrigger()) {
$this->initSettings();
$this->updateCategories();
}
}
function debugMessage ($msg) { function debugMessage ($msg) {
if ($this->_debug) { if ($this->_debug) {
$app = JFactory::getApplication(); JFactory::getApplication()->enqueueMessage($msg, 'message');
$app->enqueueMessage($msg, 'message');
} }
} }
function progressMessage ($msg) { function progressMessage ($msg) {
if ($this->_report) { if ($this->_report) {
$app = JFactory::getApplication(); JFactory::getApplication()->enqueueMessage($msg, 'message');
$app->enqueueMessage($msg, 'message');
} }
} }
...@@ -170,6 +169,16 @@ class plgSystemVMAutoParentCategories extends JPlugin { ...@@ -170,6 +169,16 @@ class plgSystemVMAutoParentCategories extends JPlugin {
} }
} }
} }
function getCategoryTree () {
$q = 'SELECT `c`.`virtuemart_category_id` , `l`.`category_name` , `cc`.`category_parent_id`
FROM `#__virtuemart_categories` AS `c`
LEFT JOIN `#__virtuemart_categories_'.VMLANG.'` AS `l` ON ( `c`.`virtuemart_category_id` = `l`.`virtuemart_category_id` )
LEFT JOIN `#__virtuemart_category_categories` AS `cc` ON ( `c`.`virtuemart_category_id` = `cc`.`category_child_id` )';
$db = JFactory::getDbo ();
$db->setQuery ($q);
$categories = $db->loadObjectList ('virtuemart_category_id');
return $categories;
}
function updateCategories() { function updateCategories() {
...@@ -179,10 +188,7 @@ class plgSystemVMAutoParentCategories extends JPlugin { ...@@ -179,10 +188,7 @@ class plgSystemVMAutoParentCategories extends JPlugin {
$prodaction = $this->params->get('normal_products', 'nothing'); $prodaction = $this->params->get('normal_products', 'nothing');
$childprodaction = $this->params->get('child_products', 'nothing'); $childprodaction = $this->params->get('child_products', 'nothing');
$app = JFactory::getApplication(); $cattree = $this->getCategoryTree();
$catmodel = VmModel::getModel('category');
$cattree = $catmodel->getCategoryTree();
// Store the names and parents for each category id // Store the names and parents for each category id
foreach ($cattree as $cat) { foreach ($cattree as $cat) {
$catnames[$cat->virtuemart_category_id] = $cat->category_name; $catnames[$cat->virtuemart_category_id] = $cat->category_name;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<license>http://www.gnu.org/licenses/gpl.html GNU/GPL v3+</license> <license>http://www.gnu.org/licenses/gpl.html GNU/GPL v3+</license>
<authorEmail>reinhold@kainhofer.com/</authorEmail> <authorEmail>reinhold@kainhofer.com/</authorEmail>
<authorUrl>http://kainhofer.com</authorUrl> <authorUrl>http://kainhofer.com</authorUrl>
<version>1.0.0</version> <version>1.1.0</version>
<description>VMAUTOCATEGORIES_DESCRIPTION</description> <description>VMAUTOCATEGORIES_DESCRIPTION</description>
<files> <files>
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
<field name="run_trigger" type="list" default="never" label="VMAUTOCATEGORIES_RUN" description ="VMAUTOCATEGORIES_RUN_DESC" > <field name="run_trigger" type="list" default="never" label="VMAUTOCATEGORIES_RUN" description ="VMAUTOCATEGORIES_RUN_DESC" >
<option value="never">VMAUTOCATEGORIES_RUN_NEVER</option> <option value="never">VMAUTOCATEGORIES_RUN_NEVER</option>
<!-- <option value="backend-login">VMAUTOCATEGORIES_RUN_BACKEND_LOGIN</option> --> <!-- <option value="backend-login">VMAUTOCATEGORIES_RUN_BACKEND_LOGIN</option> -->
<!-- <option value="frontend-login">VMAUTOCATEGORIES_RUN_FRONTEND_LOGIN</option> -->
<option value="virtuemart_startpage">VMAUTOCATEGORIES_RUN_VM_STARTPAGE</option> <option value="virtuemart_startpage">VMAUTOCATEGORIES_RUN_VM_STARTPAGE</option>
<option value="virtuemart_products">VMAUTOCATEGORIES_RUN_VM_PRODUCTPAGE</option> <option value="virtuemart_products">VMAUTOCATEGORIES_RUN_VM_PRODUCTPAGE</option>
</field> </field>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment