John Magnolia
John Magnolia

Reputation: 16793

Opencart how to test if vqmod installed?

I have written a module that uses vqmod for opencart. How can I check if vqmod is installed from within the admin module?

I would like to display a warning inside of the module that checks if vqmod is installed? Even better would be to check if it also has correct write permission to generate cached files and write to the vamod.log

What is the best way of doing this?

PS: it would be cool if you could tag questions with vqmod. I dont have enough reputation to create a new tag.

Upvotes: 7

Views: 10542

Answers (4)

Jay Gilford
Jay Gilford

Reputation: 15151

To check via code, you would need to do

global $vqmod;
if(!empty($vqmod) && is_a($vqmod, 'VQMod')) {
    // INSTALLED
} else {
    //
}

While @NADH's is along the right lines, it only checks that vqmod's class has been included, not that it's been set to the $vqmod variable

Edit

As of 2.4.0, this will no longer work, and it's recommended to use NADH's method

Upvotes: 2

jaja
jaja

Reputation: 61

/vqmod/install

if it is installed it will tell you "vqmod is already installed"

Upvotes: 6

Brad
Brad

Reputation: 15879

Based on your comments @John, since you're looking for confirmation that VQmod is installed and also executing correctly, the safest thing to do to is check for the filename you are expecting to appear in the vqmod/cache directory. You'll know the filename if you have created the vqmod/xml definition file yourself.

You could also check for the VQMod class existing like @NADH suggested, but it doesn't mean that its working correctly. A bit like writing unit tests, always assert on the desired output. In this case its' the cache file you are creating.

Upvotes: 1

Nadh
Nadh

Reputation: 7243

<?php
    if(class_exists('VQMod')) {
         // vqmod exists
    }
?>

Upvotes: 2

Related Questions