Example #1
0
 public function run()
 {
     $mProduct = new EcwidgatewayModelProducts();
     $mProduct->processUpdate();
     $this->exportFor1C($mProduct);
     $this->updateSearchData($mProduct);
 }
 public function display($tpl = null)
 {
     //$this->checkTokenAccess();
     // output as xml
     //$doc = & JFactory::getDocument();
     //$doc->setMimeEncoding('text/xml');
     $filter = array();
     $filter["descr_date"] = "today";
     $startDate = JRequest::getVar("start_date", "");
     if ($startDate != "") {
         $filter["start_date"] = $startDate;
         unset($filter["descr_date"]);
     }
     $endDate = JRequest::getVar("end_date", "");
     if ($endDate != "") {
         $filter["end_date"] = $endDate;
         unset($filter["descr_date"]);
     }
     $category_id = JRequest::getVar("category", "");
     if ($category_id) {
         $filter["category_id"] = $category_id;
     }
     $model = new EcwidgatewayModelProducts();
     $items = $model->getDataList($filter);
     $categories = $model->getCategoriesPaths();
     $this->assignRef('items', $items);
     $this->assignRef('categories', $categories);
     $this->assignRef('productsModel', $model);
     parent::display($tpl);
 }
 public function display($tpl = null)
 {
     //$this->checkTokenAccess();
     // output as xml
     //$doc = & JFactory::getDocument();
     //$doc->setMimeEncoding('text/xml');
     $filter = array();
     $category_id = JRequest::getVar("category", "");
     if ($category_id) {
         $filter["category_id"] = $category_id;
     }
     $model = new EcwidgatewayModelProducts();
     $items = $model->getDataList($filter);
     $this->assignRef('items', $items);
     parent::display($tpl);
 }
 public function save()
 {
     $option = JRequest::getWord('option');
     $model = new EcwidgatewayModelProducts();
     $row = $model->getByName($_POST["name"]);
     if (!$row) {
         print 'Error:Товар не найден в БД сайта "Лед и пламень"';
         jexit();
     }
     $data = new stdClass();
     $data->sku = $row->sku;
     $data->description = $this->replaceHtml($_POST["content"]);
     $data->ymImage = $_POST["image"];
     $d = JFactory::getDate();
     $data->descrDateAdded = $d->toMySQL();
     if (!$model->updateProduct(null, $data, array("sku"))) {
         print 'Error:Ошибка сохранения данных';
         jexit();
     }
     print "OK";
     jexit();
 }
 public function importSeasons()
 {
     $option = JRequest::getCmd('option');
     $controller = JRequest::getCmd('controller');
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     $path = JPATH_ROOT . "/tmp";
     $upload = new Zend_File_Transfer();
     $upload->setDestination($path);
     $upload->addValidator('Extension', false, array("csv"));
     $errors = array();
     $file = "products_seasons";
     $info = $upload->getFileInfo($file);
     if ($upload->isUploaded($file)) {
         if (!$upload->isValid($file)) {
             foreach ($upload->getMessages() as $k => $v) {
                 $errors[$k] = true;
             }
         }
     }
     if ($upload->receive()) {
         $mProduct = new EcwidgatewayModelProducts();
         $mProduct->processSeasonsCsv($path . "/" . $info[$file]["name"]);
         $msg = "Данные импортированы";
     } else {
         $errorMessages = array("Ошибка при загрузке файла");
         foreach ($errors as $k => $v) {
             if (isset($errors[Zend_Validate_File_Extension::FALSE_EXTENSION])) {
                 $errorMessages[] = JText::_("Недопустимое расширение файла");
             }
         }
         $msg = implode("<p>", $errorMessages);
     }
     $link = 'index.php?option=' . $option . '&controller=' . $controller;
     $this->setRedirect($link, $msg);
 }
<?php

// no direct access
defined('_JEXEC') or die('Restricted access');
require_once dirname(__FILE__) . '/helper.php';
// check for existing rockecwid component (need for shop settings)
$rokecwidPath = JPATH_SITE . '/components/com_rokecwid/helpers';
if (!file_exists($rokecwidPath . '/ecwid_catalog.php') || !file_exists($rokecwidPath . '/ecwid_product_api.php')) {
    print "Need Rokecwid component for this module";
} else {
    $bootstrap = new Ecwidgateway_Bootstrap();
    $mProduct = new EcwidgatewayModelProducts();
    $product = $mProduct->getProductOfMonth();
    $seasonProduct = $product->name;
    modEcwidCustomSearch::init();
    require JModuleHelper::getLayoutPath('mod_ecwid_customsearch');
}