News:

Looking for documentation? Take a look on our wiki

Main Menu

Media Categories in email

Started by jgm196, May 12, 2014, 21:18:12 PM

Previous topic - Next topic

jgm196

Hi, I´m trying to develop a plugin to send category information by email. The email is sent automatically with a cron.

I´m getting all the categories informatión using the category model and the function getChildCategoryList. But all the information about media isn´t sending. So I think that the problem is that this code isn´t working:

if(!empty($childList)){
         if(!class_exists('TableCategory_medias'))require(JPATH_VM_ADMINISTRATOR.DS.'tables'.DS.'category_medias.php');
         foreach($childList as $child){
            $xrefTable = new TableCategory_medias($db);
            $child->virtuemart_media_id = $xrefTable->load($child->virtuemart_category_id);
         }
      }

I don´t know if the problem is that if I`m doing this without being signed in, I can´t access to the table category_medias.

Is there any way to get the image thumbnail of a category with a SQL query? How can I get the image resized of a category?

thanks

GJC Web Design

if it just a once a seldom run cron there's no problem in just using normal queries

either get a cat-> media mapping from jos_virtuemart_category_medias then loop thru and get the media from jos_virtuemart_medias  or if your a bit of a sql guru a JOIN query to do it in less queries
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

jgm196

#2
Thanks for your reply,

I know that I can get the file name from the table virtuemart_medias using a SQL query, but if I do that, I only get the file name of the image. If I send my email without using cron (from the backend, being logged in), every works fine, but if I use cron my categories don´t have any information about media. As I said before, I think that there is a problem with this part of code in my category model:

if(!empty($childList)){
         if(!class_exists('TableCategory_medias'))require(JPATH_VM_ADMINISTRATOR.DS.'tables'.DS.'category_medias.php');
         foreach($childList as $child){
            $xrefTable = new TableCategory_medias($db);
            $child->virtuemart_media_id = $xrefTable->load($child->virtuemart_category_id);
         }
      }

If I send the email from the backend,  the helpers (mediahandler.php)(image.php)seems to work and I get al this information:

[file_url_folder] => images/stories/virtuemart/category/
[file_path_folder] => images/stories/virtuemart/category/
[file_url_folder_thumb] => images/stories/virtuemart/category/resized/
[file_name_thumb] => category1_280x165 ) ),
[file_url_thumb] => images/stories/virtuemart/category/resized/category1_280x165.png
[file_url] => images/stories/virtuemart/category/category1.png )

So, how can I get all this information about paths and thumbs using a query  or how can I modify my code to get it works?

Milbo

Use the function in vmmodel. There it is "explained".
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jgm196

#4
My problem is that I can´t get any media_id from categories. So, if a don´t have any media_id I can´t use the function addImages inside vmmodel.

Additional information:

I´ve just try using categoryModel->getCategory, and it works, so this code is working:

$xrefTable = $this->getTable('category_medias');
$this->_data->virtuemart_media_id = $xrefTable->load((int)$this->_id);

And the code inside getCategorychildlist, don´t:

if(!empty($childList)){
         if(!class_exists('TableCategory_medias'))require(JPATH_VM_ADMINISTRATOR.DS.'tables'.DS.'category_medias.php');
         foreach($childList as $child){
            $xrefTable = new TableCategory_medias($db);
            $child->virtuemart_media_id = $xrefTable->load($child->virtuemart_category_id);
         }
      }

Any idea?

Milbo

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