Esempio n. 1
0
 /**
  * Retrieve the category list
  * with category description for one product
  *
  * @param int $productId
  * @param int $languageId
  * @return array Where the keys are the cateogory id
  */
 public function getCategoriesByProductId($productId, $languageId = null)
 {
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     return $this->select('*')->joinLeft('catalog_category_description', 'ccd.category_id = cpc.category_id AND ccd.language_id = ' . $languageId, '*')->where('cpc.product_id = ?', $productId)->fetchAssoc();
 }
Esempio n. 2
0
 /**
  *
  * @param int $valueSetId
  * @param int $languageId
  * @return array
  */
 public function getCustomValues($valueSetId, $languageId = null)
 {
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     return $this->select('id')->join('account_customer_valueset_value_label', 'acvvl.valueset_value_id = acvv.id', 'label')->where('acvv.is_active = 1')->where('acvv.customer_valueset_id = ?', $valueSetId)->where('acvvl.language_id = ?', $languageId)->order('acvv.sort_order')->fetchPairs();
 }
Esempio n. 3
0
 private function _initSeoParams($keywords)
 {
     if (!sizeof($keywords)) {
         return array();
     }
     $rowset = Axis::single('catalog/hurl')->select()->where('key_word IN (?)', $keywords)->where('site_id = ?', Axis::getSiteId())->fetchAssoc();
     foreach ($rowset as $row) {
         switch ($row['key_type']) {
             case 'c':
                 $this->_params['cat']['value'] = $row['key_id'];
                 if (empty($this->_params['cat']['seo'])) {
                     $this->_params['cat']['seo'] = $row['key_word'];
                 } else {
                     $this->_params['cat']['seo'] .= '/' . $row['key_word'];
                 }
                 break;
             case 'p':
                 $this->_params['product']['value'] = $row['key_id'];
                 $this->_params['product']['seo'] = $row['key_word'];
                 $this->getRequest()->setParam('product', $row['key_id']);
                 break;
             case 'm':
                 $mDescription = Axis::single('catalog/product_manufacturer_description')->select(array('title', 'description'))->where('manufacturer_id = ?', $row['key_id'])->where('language_id = ?', Axis_Locale::getLanguageId())->fetchRow();
                 $this->_params['manufacturer'] = array('value' => $row['key_id'], 'seo' => $row['key_word'], 'title' => $mDescription->title, 'description' => $mDescription->description);
                 break;
             default:
                 break;
         }
     }
 }
Esempio n. 4
0
 /**
  * Construct, create index
  *
  * @param string $indexPath[optional]
  * @param string $encoding[optional]
  * @throws Axis_Exception
  */
 public function __construct(array $params)
 {
     $encoding = $this->_encoding;
     $indexPath = array_shift($params);
     if (count($params)) {
         $encoding = array_shift($params);
     }
     if (null === $indexPath) {
         $site = Axis::getSite()->id;
         $locale = Axis::single('locale/language')->find(Axis_Locale::getLanguageId())->current()->locale;
         $indexPath = Axis::config()->system->path . '/var/index/' . $site . '/' . $locale;
     }
     if (!is_readable($indexPath)) {
         throw new Axis_Exception(Axis::translate('search')->__('Please, update search indexes, to enable search functionality'));
     }
     /*
     $mySimilarity = new Axis_Similarity();
     Zend_Search_Lucene_Search_Similarity::setDefault($mySimilarity);
     */
     Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding($encoding);
     // add filter by words
     $stopWords = array('a', 'an', 'at', 'the', 'and', 'or', 'is', 'am');
     $stopWordsFilter = new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords);
     $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
     $analyzer->addFilter($stopWordsFilter);
     Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
     $this->_index = Zend_Search_Lucene::open($indexPath);
     $this->_encoding = $encoding;
 }
 public function indexAction()
 {
     $this->view->pageTitle = Axis::translate('account')->__('Manage Customers');
     if ($this->_hasParam('customerId')) {
         $this->view->customerId = $this->_getParam('customerId');
     }
     $this->view->userForm = array();
     $this->view->valueSet = array();
     $modelCustomerValueSetValue = Axis::model('account/Customer_ValueSet_Value');
     $modelCustomerFields = Axis::model('account/customer_field');
     $fieldGroups = Axis::single('account/Customer_FieldGroup')->getGroups(Axis_Locale::getLanguageId());
     foreach ($fieldGroups as $fieldGroup) {
         //getting all fields
         $this->view->userForm[$fieldGroup['id']]['title'] = $fieldGroup['title'];
         $this->view->userForm[$fieldGroup['id']]['is_active'] = $fieldGroup['is_active'];
         $this->view->userForm[$fieldGroup['id']]['fields'] = $modelCustomerFields->getFieldsByGroup($fieldGroup['id']);
         //getting only used valuesets
         foreach ($this->view->userForm[$fieldGroup['id']]['fields'] as $fd) {
             if (!isset($fd['customer_valueset_id'])) {
                 continue;
             }
             $this->view->valueSet[$fd['customer_valueset_id']]['values'] = $modelCustomerValueSetValue->getValues($fd['customer_valueset_id']);
         }
     }
     $this->render();
 }
Esempio n. 6
0
 protected function _initCategory($id)
 {
     $categoryRow = Axis::single('catalog/category')->find($id)->current();
     if (!$categoryRow || $categoryRow->status != 'enabled') {
         return false;
     }
     $parentItems = $categoryRow->cache()->getParentItems();
     foreach ($parentItems as $_category) {
         if ($_category['status'] != 'enabled') {
             return false;
         }
         $_uri = $this->view->hurl(array('cat' => array('value' => $_category['id'], 'seo' => $_category['key_word'])));
         $this->_helper->breadcrumbs(array('label' => $_category['name'], 'uri' => $_uri));
     }
     $categoryDescriptionRow = Axis::single('catalog/category_description')->find($id, Axis_Locale::getLanguageId())->current();
     if (!$categoryDescriptionRow) {
         return false;
     } else {
         $this->view->category = array_merge($categoryRow->toArray(), $categoryDescriptionRow->toArray());
         $this->view->pageTitle = $categoryDescriptionRow->name;
         $this->view->meta()->setDescription($categoryDescriptionRow->meta_description)->setTitle($categoryDescriptionRow->meta_title)->setKeywords($categoryDescriptionRow->meta_keyword);
     }
     Zend_Registry::set('catalog/current_category', $categoryRow);
     return $this->view->category;
 }
Esempio n. 7
0
 protected function _beforeRender()
 {
     $modelQuestion = Axis::single('poll/question');
     if ($this->hasQuestionId()) {
         $this->_questionId = $this->getQuestionId();
         $this->setQuestionId(null);
     } else {
         $this->_questionId = $modelQuestion->getOneNotVotedQuestionIdByCookie();
     }
     if (!$this->_questionId) {
         return false;
     }
     $question = $modelQuestion->getQuestionWithAnswers($this->_questionId, Axis_Locale::getLanguageId());
     if (!$question) {
         return false;
     }
     $results = array();
     $totalVoteCount = 0;
     $this->_showResult = (bool) $this->getShowResult();
     $this->setShowResult(null);
     if ($this->_showResult) {
         $questionRow = Axis::single('poll/question')->find($this->_questionId)->current();
         $results = $questionRow->getResults();
         $totalVoteCount = $questionRow->getTotalVoteCount();
     }
     $this->setFromArray(array('question' => $question, 'answers' => $question['answers'], 'results' => $results, 'status' => $this->_showResult, 'total_count' => $totalVoteCount));
     return true;
 }
Esempio n. 8
0
 public function indexAction()
 {
     $this->setCanonicalUrl($this->view->url(array(), 'cms', true));
     $this->setTitle(Axis::translate('cms')->__('Pages'), null, false);
     $categories = Axis::single('cms/category')->select(array('id', 'parent_id'))->addCategoryContentTable()->columns(array('ccc.link', 'ccc.title'))->addActiveFilter()->addSiteFilter(Axis::getSiteId())->addLanguageIdFilter(Axis_Locale::getLanguageId())->order('cc.parent_id')->where('ccc.link IS NOT NULL')->fetchAssoc();
     $pages = Axis::single('cms/page')->select(array('id', 'name'))->join(array('cpca' => 'cms_page_category'), 'cp.id = cpca.cms_page_id', 'cms_category_id')->join('cms_page_content', 'cp.id = cpc.cms_page_id', array('link', 'title'))->where('cp.is_active = 1')->where('cpc.language_id = ?', Axis_Locale::getLanguageId())->where('cpca.cms_category_id IN (?)', array_keys($categories))->order('cpca.cms_category_id')->fetchAssoc();
     $menu = new Zend_Navigation();
     foreach ($categories as $_category) {
         $title = empty($_category['title']) ? $_category['link'] : $_category['title'];
         $page = new Zend_Navigation_Page_Mvc(array('category_id' => $_category['id'], 'label' => $title, 'title' => $title, 'route' => 'cms_category', 'params' => array('cat' => $_category['link']), 'class' => 'icon-folder'));
         $_container = $menu->findBy('category_id', $_category['parent_id']);
         if (null === $_container) {
             $_container = $menu;
         }
         $_container->addPage($page);
     }
     foreach ($pages as $_page) {
         $title = empty($_page['title']) ? $_page['link'] : $_page['title'];
         $page = new Zend_Navigation_Page_Mvc(array('label' => $title, 'title' => $title, 'route' => 'cms_page', 'params' => array('page' => $_page['link']), 'class' => 'icon-page'));
         $_container = $menu->findBy('category_id', $_page['cms_category_id']);
         $_container->addPage($page);
     }
     $this->view->menu = $menu;
     $this->render();
 }
Esempio n. 9
0
 public function init()
 {
     $categories = Axis::single('catalog/category')->select('*')->addName(Axis_Locale::getLanguageId())->addKeyWord()->order('cc.lft')->addSiteFilter(Axis::getSiteId())->addDisabledFilter()->fetchAll();
     if (!is_array($this->_activeCategories)) {
         $this->_activeCategories = array();
         if (Zend_Registry::isRegistered('catalog/current_category')) {
             $this->_activeCategories = array_keys(Zend_Registry::get('catalog/current_category')->cache()->getParentItems());
         }
     }
     $container = $_container = new Zend_Navigation();
     $lvl = 0;
     $view = $this->getView();
     foreach ($categories as $_category) {
         $uri = $view->hurl(array('cat' => array('value' => $_category['id'], 'seo' => $_category['key_word']), 'controller' => 'catalog', 'action' => 'view'), false, true);
         $class = 'nav-' . str_replace('.', '-', $_category['key_word']);
         $page = new Zend_Navigation_Page_Uri(array('label' => $_category['name'], 'title' => $_category['name'], 'uri' => $uri, 'order' => $_category['lft'], 'class' => $class, 'visible' => 'enabled' === $_category['status'] ? true : false, 'active' => in_array($_category['id'], $this->_activeCategories)));
         $lvl = $lvl - $_category['lvl'] + 1;
         for ($i = 0; $i < $lvl; $i++) {
             $_container = $_container->getParent();
         }
         $lvl = $_category['lvl'];
         $_container->addPage($page);
         $_container = $page;
     }
     $this->setData('menu', $container);
     return true;
 }
Esempio n. 10
0
 public function indexAction()
 {
     $this->setTitle(Axis::translate('poll')->__('Polls'));
     $languageId = Axis_Locale::getLanguageId();
     $questionIds = array();
     if ($this->_hasParam('questionId')) {
         $questionIds[] = array('id' => $this->_getParam('questionId'));
     }
     $modelVote = Axis::single('poll/vote');
     $modelAnswer = Axis::single('poll/answer');
     $questions = Axis::single('poll/question')->getQuestions($languageId, $questionIds);
     $answers = array();
     foreach ($modelAnswer->getAnswers($languageId) as $answer) {
         $answers[$answer['question_id']][] = $answer;
     }
     $votes = $modelVote->getVoteCount();
     $customerVotes = $modelVote->getVoteCount(Axis::getCustomerId());
     $results = $modelVote->getResults();
     $cookieVotedQuestionIds = $modelVote->getQuestionIdsFromCookie();
     $showResult = (bool) $this->_getParam('showResult', false);
     foreach ($questions as &$question) {
         $question['answer'] = isset($answers[$question['id']]) ? $answers[$question['id']] : array();
         $isVoted = $showResult || in_array($question['id'], $cookieVotedQuestionIds) || isset($customerVotes[$question['id']]) && 0 < $customerVotes[$question['id']];
         $question['status'] = false;
         if ($isVoted) {
             $question['results'] = isset($results[$question['id']]) ? $results[$question['id']] : array();
             $question['totalCount'] = $votes[$question['id']];
             $question['status'] = true;
         }
     }
     $this->view->questions = $questions;
     $this->render('all');
 }
Esempio n. 11
0
 /**
  * Adds product_name column to select
  *
  * @param integer $languageId [optional]
  * @return Axis_Tag_Model_Customer_Select
  */
 public function addProductDescription($languageId = null)
 {
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     return $this->joinLeft('catalog_product_description', 'tp.product_id = cpd.product_id AND cpd.language_id = ' . $languageId, array('product_name' => 'name'));
 }
Esempio n. 12
0
 /**
  * Add all columns from cms_page_content table to select
  *
  * @param int $languageId [optional]
  * @return  Axis_Admin_Model_Cms_Page_Select
  */
 public function addContent($languageId = null)
 {
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     $this->joinLeft('cms_page_content', $this->getAdapter()->quoteInto('cp.id = cpc.cms_page_id AND cpc.language_id = ?', $languageId), '*');
     return $this;
 }
Esempio n. 13
0
 public function getPages($languageId = null)
 {
     if (null == $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     /*get pages*/
     return Axis::single('cms/page_content')->select(array('link', 'title'))->joinInner(array('cpca' => 'cms_page_category'), 'cpc.cms_page_id = cpca.cms_page_id')->joinInner('cms_page', 'cp.id = cpc.cms_page_id')->where('cpca.cms_category_id = ?', $this->id)->where('cpc.language_id = ?', $languageId)->where('cp.is_active = 1')->where('cpc.link IS NOT NULL')->fetchAll();
 }
Esempio n. 14
0
 /**
  *
  * @param array $fieldGroupIds
  * @param int $languageId
  * @return array
  */
 public function getCustomGroups($fieldGroupIds, $languageId = null)
 {
     if (!is_array($fieldGroupIds)) {
         $fieldGroupIds = array($fieldGroupIds);
     }
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     return $this->select(array('id', 'sort_order', 'name'))->join('account_customer_fieldgroup_label', 'acfl.customer_field_group_id = acf.id', 'group_label')->where('acf.id IN(?)', $fieldGroupIds)->where('acfl.language_id = ?', $languageId)->fetchAll();
 }
Esempio n. 15
0
 public function getResults()
 {
     $languageId = Axis_Locale::getLanguageId();
     $rowset = $this->select(array('answer_id', 'cnt' => 'COUNT(*)'))->join('poll_answer', 'pa.id = pv.answer_id', 'question_id')->where('pa.language_id = ?', $languageId)->group('pv.answer_id')->order('cnt')->fetchAssoc();
     $dataset = array();
     foreach ($rowset as $row) {
         $dataset[$row['question_id']][$row['answer_id']] = $row;
     }
     return $dataset;
 }
Esempio n. 16
0
 /**
  *
  * @return Axis_Cms_Model_Page_Content_Row
  */
 public function getContent()
 {
     $languageId = Axis_Locale::getLanguageId();
     $columns = array('title', 'content', 'meta_keyword', 'meta_description', 'meta_title');
     $row = Axis::model('cms/page_content')->select($columns)->joinLeft('cms_page', 'cp.id = cpc.cms_page_id', array('layout'))->where('cpc.language_id = ?', $languageId)->where('cpc.cms_page_id = ?', $this->id)->fetchRow();
     if (!$row) {
         return false;
     }
     $row->content = $row->getContent();
     return $row;
 }
Esempio n. 17
0
 /**
  * @param mixed $productIds
  * @return array [product_id => images_array, ...]
  */
 public function getList($productIds)
 {
     if (!is_array($productIds)) {
         $productIds = array($productIds);
     }
     $select = $this->select('*')->joinLeft('catalog_product_image_title', 'cpi.id = cpit.image_id AND cpit.language_id = ' . Axis_Locale::getLanguageId(), 'title')->where('cpi.product_id IN (?)', $productIds)->order('cpi.sort_order')->order('cpi.id DESC');
     $dataset = array_fill_keys($productIds, array());
     foreach ($select->fetchAssoc() as $id => $image) {
         $dataset[$image['product_id']][$id] = $image;
     }
     return $dataset;
 }
Esempio n. 18
0
 public function init()
 {
     $this->addElement('text', 'email', array('required' => true, 'label' => 'Email', 'class' => 'input-text required email', 'validators' => array('EmailAddress', new Axis_Validate_Exists(Axis::single('account/customer'), 'email', "id <> " . Axis::getCustomerId() . " AND site_id = " . Axis::getSiteId()))));
     $this->addElement('text', 'firstname', array('required' => true, 'label' => 'Firstname', 'class' => 'input-text required'));
     $this->addElement('text', 'lastname', array('required' => true, 'label' => 'Lastname', 'class' => 'input-text required'));
     $this->addDisplayGroup(array('email', 'firstname', 'lastname'), 'login', array('legend' => 'General information'));
     $rows = Axis::single('account/customer_field')->getFields();
     $groupsFields = array();
     foreach ($rows as $row) {
         $field = 'field_' . $row['id'];
         $config = array('id' => 'field_' . $row['name'], 'required' => (bool) $row['required'], 'label' => $row['field_label'], 'class' => in_array($row['field_type'], array('textarea', 'text')) ? 'input-text' : '');
         if ($row['field_type'] == 'textarea') {
             $config['rows'] = 6;
             $config['cols'] = 60;
         }
         $this->addElement($row['field_type'], $field, $config);
         $el = $this->getElement($field);
         if ($row['required']) {
             $el->addValidator('NotEmpty')->setAttrib('class', $el->getAttrib('class') . ' required');
         }
         if (!empty($row['validator'])) {
             $el->addValidator($row['validator']);
             if ($row['validator'] == 'Date') {
                 $el->setAttrib('class', $el->getAttrib('class') . ' input-date');
             }
         }
         if (!empty($row['axis_validator'])) {
             $el->addValidator(new $row['axis_validator']());
         }
         if (isset($row['customer_valueset_id'])) {
             $values = Axis::single('account/Customer_ValueSet_Value')->getCustomValues($row['customer_valueset_id'], Axis_Locale::getLanguageId());
             if (method_exists($el, 'setMultiOptions')) {
                 $el->setMultiOptions($values);
             }
         }
         $groupsFields[$row['customer_field_group_id']][$row['id']] = $field;
     }
     /* add field groups */
     if (count($groupsFields)) {
         $groups = Axis::single('account/customer_fieldGroup')->getCustomGroups(array_keys($groupsFields), Axis_Locale::getLanguageId());
         foreach ($groups as $row) {
             $this->addDisplayGroup(array_values($groupsFields[$row['id']]), empty($row['name']) ? $row['id'] : $row['name'], array('legend' => $row['group_label']));
             $this->getDisplayGroup(empty($row['name']) ? $row['id'] : $row['name'])->setDisableTranslator(true);
         }
     }
     $this->addElement('checkbox', 'change_password_toggle', array('label' => 'Change password', 'onchange' => "togglePasswordForm(this.checked)"));
     $this->addElement('password', 'password', array('disabled' => 'disabled', 'label' => 'New password', 'class' => 'input-text required password', 'validators' => array('NotEmpty', new Axis_Validate_PasswordConfirmation())));
     $this->addElement('password', 'password_confirm', array('disabled' => 'disabled', 'label' => 'Confirm new password', 'class' => 'input-text required password'));
     $this->addElement('password', 'password_current', array('disabled' => 'disabled', 'label' => 'Current password', 'class' => 'input-text required password', 'validators' => array('NotEmpty', new Axis_Validate_PasswordEqual(Axis::getCustomer()->password))));
     $this->addDisplayGroup(array('password_current', 'password', 'password_confirm'), 'change_password', array('legend' => 'Change password', 'style' => 'display: none;'));
     $this->addElement('button', 'submit', array('type' => 'submit', 'class' => 'button', 'label' => 'Save'));
     $this->addActionBar(array('submit'));
 }
Esempio n. 19
0
 /**
  * Add description table to select
  *
  * @param mixed $languageId If false - description will join all available languages
  * @return Axis_Catalog_Model_Product_Manufacturer_Select
  */
 public function addDescription($languageId = null)
 {
     if (false === $languageId) {
         $joinOn = 'cpm.id = cpmd.manufacturer_id';
     } else {
         if (null === $languageId) {
             $languageId = Axis_Locale::getLanguageId();
         }
         $joinOn = 'cpm.id = cpmd.manufacturer_id AND language_id = ' . $languageId;
     }
     return $this->joinLeft('catalog_product_manufacturer_description', $joinOn, '*');
 }
Esempio n. 20
0
 private function _getValues($set)
 {
     $vf = '[';
     if ($set && $this->_valueset[$set]['values']) {
         foreach ($this->_valueset[$set]['values'] as $value) {
             $label = empty($value['label' . Axis_Locale::getLanguageId()]) ? '' : addslashes($value['label' . Axis_Locale::getLanguageId()]);
             $vf .= "['{$value['id']}', '{$label}'],";
         }
     }
     $vf = substr($vf, -1) == ',' ? substr($vf, 0, -1) : $vf;
     $vf .= ']';
     return $vf;
 }
Esempio n. 21
0
 public function init()
 {
     $this->addElement('text', 'email', array('required' => true, 'label' => 'Email', 'class' => 'input-text required email', 'description' => 'Email will be used to login into your account', 'validators' => array('EmailAddress', new Axis_Validate_Exists(Axis::single('account/customer'), 'email', 'site_id = ' . Axis::getSiteId()))));
     $this->addElement('password', 'password', array('required' => true, 'label' => 'Password', 'class' => 'input-text required password', 'validators' => array('NotEmpty', new Axis_Validate_PasswordConfirmation())));
     $this->addElement('password', 'password_confirm', array('required' => true, 'label' => 'Confirm Password', 'class' => 'input-text required password'));
     $this->addElement('text', 'firstname', array('required' => true, 'label' => 'Firstname', 'class' => 'input-text required'));
     $this->addElement('text', 'lastname', array('required' => true, 'label' => 'Lastname', 'class' => 'input-text required'));
     $this->addDisplayGroup(array('email', 'password', 'password_confirm', 'firstname', 'lastname'), 'login', array('legend' => 'General information'));
     $rows = Axis::single('account/customer_field')->getFields();
     $groupsFields = array();
     foreach ($rows as $row) {
         $field = 'field_' . $row['id'];
         $config = array('id' => 'field_' . $row['name'], 'required' => (bool) $row['required'], 'label' => $row['field_label'], 'class' => in_array($row['field_type'], array('textarea', 'text')) ? 'input-text' : '');
         if ($row['field_type'] == 'textarea') {
             $config['rows'] = 6;
             $config['cols'] = 60;
         }
         $this->addElement($row['field_type'], $field, $config);
         $el = $this->getElement($field);
         if ($row['required']) {
             $el->addValidator('NotEmpty')->setAttrib('class', $el->getAttrib('class') . ' required');
         }
         if (!empty($row['validator'])) {
             $el->addValidator($row['validator']);
             if ($row['validator'] == 'Date') {
                 $el->setAttrib('class', $el->getAttrib('class') . ' input-date');
             }
         }
         if (!empty($row['axis_validator'])) {
             $el->addValidator(new $row['axis_validator']());
         }
         if (isset($row['customer_valueset_id'])) {
             $values = Axis::single('account/Customer_ValueSet_Value')->getCustomValues($row['customer_valueset_id'], Axis_Locale::getLanguageId());
             if (method_exists($el, 'setMultiOptions')) {
                 $el->setMultiOptions($values);
             }
         }
         $groupsFields[$row['customer_field_group_id']][$row['id']] = $field;
     }
     /* add field groups */
     if (count($groupsFields)) {
         $groups = Axis::single('account/customer_fieldGroup')->getCustomGroups(array_keys($groupsFields), Axis_Locale::getLanguageId());
         foreach ($groups as $row) {
             $groupName = empty($row['name']) ? $row['id'] : $row['name'];
             $this->addDisplayGroup(array_values($groupsFields[$row['id']]), $groupName, array('legend' => $row['group_label']));
             $this->getDisplayGroup($groupName)->setDisableTranslator(true);
         }
     }
     $this->addElement('button', 'submit', array('type' => 'submit', 'class' => 'button', 'label' => 'Register'));
     $this->addActionBar(array('submit'));
 }
Esempio n. 22
0
 /**
  * Retrieve the set of child categories
  *
  * @param bool $deep [optional]
  * @param bool $activeOnly [optional]
  * @param integer $languageId [optional]
  * @return array
  */
 public function getChildItems($deep = false, $activeOnly = false, $languageId = null)
 {
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     $select = $this->select()->from('catalog_category')->joinLeft('catalog_category_description', 'ccd.category_id = cc.id AND ccd.language_id = ' . $languageId, 'name')->joinLeft('catalog_hurl', "cc.id = ch.key_id AND ch.key_type = 'c'", 'key_word')->where("cc.lft BETWEEN {$this->lft} AND {$this->rgt}")->where("cc.site_id = {$this->site_id}")->order('cc.lft');
     if (!$deep) {
         $select->where("cc.lvl = " . ($this->lvl + 1));
     }
     if ($activeOnly) {
         $select->where("cc.status = 'enabled'");
     }
     return $select->fetchAll();
 }
Esempio n. 23
0
 /**
  * Retrieve the list of products including product hurl, options and attributes
  *
  * @param id $shoppingCartId
  * @return array
  */
 public function getProducts($shoppingCartId)
 {
     $registryIndex = 'checkout/cart_products_' . $shoppingCartId;
     if (Zend_Registry::isRegistered($registryIndex)) {
         return Zend_Registry::get($registryIndex);
     }
     $select = $this->select('*')->where('shopping_cart_id = ?', $shoppingCartId);
     if (!$select->fetchRow()) {
         return array();
     }
     $languageId = Axis_Locale::getLanguageId();
     $select->joinLeft('catalog_product', 'cp.id = ccp.product_id', array('sku', 'price', 'image_thumbnail', 'image_listing', 'image_base'))->joinLeft('catalog_product_description', 'cpd.product_id = ccp.product_id AND cpd.language_id = ' . $languageId, array('name', 'description', 'image_seo_name'))->joinLeft('catalog_hurl', 'ch.key_id = cp.id AND ch.key_type = "p"', 'key_word')->joinLeft('catalog_product_stock', 'cps.product_id = cp.id', 'decimal')->joinLeft('checkout_cart_product_attribute', 'ccpa.shopping_cart_product_id = ccp.id', array('shoppingCartProductAttributeId' => 'id', 'product_attribute_value'))->joinLeft('catalog_product_attribute', 'cpa.id = ccpa.product_attribute_id')->joinLeft('catalog_product_option', 'cpo.id = cpa.option_id', 'input_type')->joinLeft('catalog_product_option_text', 'cpot.option_id = cpa.option_id AND cpot.language_id = ' . $languageId, array('option_name' => 'name'))->joinLeft('catalog_product_option_value_text', 'cpovt.option_value_id = cpa.option_value_id AND cpovt.language_id = ' . $languageId, array('value_name' => 'name'))->order(array('ccp.product_id', 'cpo.id'))->limit();
     //reset limit 1
     $products = array();
     $productIds = array();
     foreach ($select->fetchAll() as $row) {
         if (!isset($products[$row['id']])) {
             $productIds[$row['product_id']] = $row['product_id'];
             $products[$row['id']] = $row;
             $products[$row['id']]['final_price'] = (double) $row['final_price'];
             $products[$row['id']]['decimal'] = (bool) $row['decimal'];
             $products[$row['id']]['attributes'] = array();
         }
         if (!isset($row['shoppingCartProductAttributeId'])) {
             continue;
         }
         $attributte = array('product_option' => $row['option_name']);
         switch ($row['input_type']) {
             case Axis_Catalog_Model_Product_Option::TYPE_SELECT:
             case Axis_Catalog_Model_Product_Option::TYPE_RADIO:
                 $attributte['product_option_value'] = $row['value_name'];
                 break;
             case Axis_Catalog_Model_Product_Option::TYPE_CHECKBOX:
                 $attributte['product_option_value'] = isset($row['value_name']) ? $row['value_name'] : Axis::translate('checkout')->__('Checked');
                 break;
             default:
                 $attributte['product_option_value'] = $row['product_attribute_value'];
                 break;
         }
         $products[$row['id']]['attributes'][$row['shoppingCartProductAttributeId']] = $attributte;
     }
     $images = Axis::single('catalog/product_image')->getList($productIds);
     foreach ($products as $product) {
         $products[$product['id']]['images'] = $images[$product['product_id']];
     }
     Zend_Registry::set($registryIndex, $products);
     return Zend_Registry::get($registryIndex);
 }
Esempio n. 24
0
 /**
  * @param name $fieldName
  * @param int $languageId
  * @return mixed
  */
 public function getExtraField($fieldName, $languageId = null)
 {
     if (!$languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     $row = Axis::model('account/customer_detail')->select('*')->join('account_customer_field', 'acd.customer_field_id = acf.id')->where('acd.customer_id = ? ', $this->id)->where('acf.name =  ?', $fieldName)->fetchRow();
     if (!$row) {
         return false;
     }
     if ($row->data) {
         return $row->data;
     }
     if ($row->customer_valueset_value_id) {
         return Axis::model('account/customer_valueSet_value_label')->select('label')->where('valueset_value_id = ?', $row->customer_valueset_value_id)->where('language_id = ?', $languageId)->fetchCol();
     }
     return false;
 }
Esempio n. 25
0
 /**
  * Return customer tags with count of products for each
  *
  * @param int $customerId
  * @param bool $getProductNames
  * @param int $languageId
  * @return array
  */
 public function getMyWithWeight($customerId = null, $getProductNames = false, $languageId = null)
 {
     if (null === $customerId) {
         $customerId = Axis::getCustomerId();
     }
     if (!$customerId) {
         return false;
     }
     $select = $this->select(array('*', new Zend_Db_Expr('COUNT(*) AS weight')))->joinLeft('tag_product', 'tp.customer_tag_id = tc.id', 'product_id')->where('tc.customer_id = ?', $customerId)->where('tc.site_id = ?', Axis::getSiteId())->where('tc.status = ?', self::STATUS_APPROVED)->group('tc.id');
     if ($getProductNames) {
         if (null === $languageId) {
             $languageId = Axis_Locale::getLanguageId();
         }
         $select->joinLeft('catalog_product_description', 'pd.product_id = tp.product_id AND pd.language_id = ' . $languageId, array('product_name' => 'name'));
     }
     return $select->query()->fetchAll();
 }
Esempio n. 26
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $db = Axis::db();
     $this->setAttrib('id', 'form-customer');
     $this->addElement('select', 'site_id', array('label' => 'Site'));
     $this->getElement('site_id')->setMultiOptions(Axis::model('core/option_site')->toArray());
     $this->addElement('text', 'email', array('required' => true, 'label' => 'Email'));
     $this->addElement('password', 'password', array('label' => 'Password'));
     $this->addElement('text', 'firstname', array('required' => true, 'label' => 'Firstname', 'class' => 'input-text required'));
     $this->addElement('text', 'lastname', array('required' => true, 'label' => 'Lastname', 'class' => 'input-text required'));
     $this->addElement('checkbox', 'is_active', array('label' => 'Active'));
     $this->addDisplayGroup(array('site_id', 'email', 'password', 'firstname', 'lastname', 'is_active'), 'login', array('legend' => 'General information'));
     $rows = Axis::single('account/customer_field')->getFields();
     $groupsFields = array();
     foreach ($rows as $row) {
         $field = 'field_' . $row['id'];
         $this->addElement($row['field_type'], $field, array('required' => (bool) $row['required'], 'label' => $row['field_label']));
         if ($row['required']) {
             $this->getElement($field)->addValidator('NotEmpty');
         }
         if (!empty($row['validator'])) {
             $this->getElement($field)->addValidator($row['validator']);
             if ($row['validator'] == 'Date') {
                 $this->getElement($field)->setAttrib('class', 'date-picker');
             }
         }
         if (isset($row['customer_valueset_id'])) {
             $values = Axis::single('account/Customer_ValueSet_Value')->getCustomValues($row['customer_valueset_id'], Axis_Locale::getLanguageId());
             $this->getElement($field)->setMultiOptions($values);
         }
         $groupsFields[$row['customer_field_group_id']][$row['id']] = $field;
     }
     /* add field groups */
     if (count($groupsFields)) {
         $groups = Axis::single('account/customer_fieldGroup')->getCustomGroups(array_keys($groupsFields), Axis_Locale::getLanguageId());
         foreach ($groups as $row) {
             $this->addDisplayGroup(array_values($groupsFields[$row['id']]), 'group_' . $row['id'], array('legend' => $row['group_label']));
             $this->getDisplayGroup('group_' . $row['id'])->setDisableTranslator(true);
         }
     }
 }
Esempio n. 27
0
 private function _initForm()
 {
     $this->view->sites = Axis_Collect_Site::collect();
     $this->view->customerGroups = Axis_Collect_CustomerGroup::collect();
     $this->view->manufactures = Axis_Collect_Manufacturer::collect();
     $languageId = Axis_Locale::getLanguageId();
     $this->view->categoryTrees = Axis::single('catalog/category')->select('*')->addName($languageId)->addKeyWord()->order('cc.lft')->fetchAllAndSortByColumn('site_id');
     $select = Axis::model('catalog/product_option_value')->select('*')->joinLeft('catalog_product_option_value_text', 'cpov.id = cpovt.option_value_id', 'name')->where('cpovt.language_id = ?', $languageId);
     $valuesetValues = array();
     foreach ($select->fetchAll() as $_row) {
         $valuesetValues[$_row['valueset_id']][$_row['id']] = $_row['name'];
     }
     $select = Axis::single('catalog/product_option')->select('*')->addNameAndDescription($languageId);
     $attributes = array();
     foreach ($select->fetchAll() as $_option) {
         if (isset($valuesetValues[$_option['valueset_id']])) {
             $attributes[$_option['id']] = array('name' => $_option['name'], 'option' => $valuesetValues[$_option['valueset_id']]);
         }
     }
     $this->view->attributes = $attributes;
 }
Esempio n. 28
0
 /**
  * Retrieve the array of all avalable ratings
  * 
  * @param bool $enabledOnly
  * @param bool $currentLanguageOnly
  * @return array
  */
 public function getList($enabledOnly = true, $currentLanguageOnly = true)
 {
     $select = $this->select('*');
     $on = 'crrt.rating_id = crr.id';
     if ($currentLanguageOnly) {
         $on .= ' AND crrt.language_id = ' . Axis_Locale::getLanguageId();
     }
     $select->joinLeft('community_review_rating_title', $on, array('title', 'language_id'));
     $select->order('crrt.title DESC');
     if ($enabledOnly) {
         $select->where('status = ?', 'enabled');
     }
     $result = array();
     foreach ($select->fetchAll() as $rating) {
         if (!isset($result[$rating['id']])) {
             $result[$rating['id']] = array('id' => $rating['id'], 'name' => $rating['name'], 'status' => $rating['status'], 'title' => $rating['title']);
         }
         if (!empty($rating['language_id'])) {
             $result[$rating['id']]['title_' . $rating['language_id']] = $rating['title'];
         }
     }
     return array_values($result);
 }
Esempio n. 29
0
 public function getResultAction()
 {
     $questionId = $this->_getParam('id', false);
     if (!$questionId) {
         return $this->_helper->json->sendFailure();
     }
     $results = Axis::single('poll/question')->find($questionId)->current()->getResults();
     $data = Axis::single('poll/answer')->getAnswers(Axis_Locale::getLanguageId(), $questionId);
     foreach ($data as &$answer) {
         $answer['count'] = isset($results[$answer['id']]['cnt']) ? $results[$answer['id']]['cnt'] : 0;
     }
     return $this->_helper->json->setData($data)->sendSuccess();
 }
Esempio n. 30
0
 /**
  * Retrieve one-dimensional array of categories where the product lies in,
  * including their parent categories
  *
  * @param int $productId
  * @param int $languageId   [optional]
  * @param int $siteId       [optional]
  * @return array
  */
 public function getRelatedCategoriesByProductId($productId, $languageId = null, $siteId = null)
 {
     if (null === $languageId) {
         $languageId = Axis_Locale::getLanguageId();
     }
     if (null === $siteId) {
         $siteId = Axis::getSiteId();
     }
     return $this->select()->from(array('cc' => 'catalog_category'))->joinLeft(array('cc1' => 'catalog_category'), 'cc.lft BETWEEN cc1.lft AND cc1.rgt', '*')->joinInner('catalog_product_category', 'cc.id = cpc.category_id')->joinInner('catalog_hurl', 'ch.key_id = cc1.id', 'key_word')->joinInner('catalog_category_description', 'ccd.category_id = cc1.id', array('id' => 'category_id', 'name', 'meta_title', 'meta_description', 'meta_keyword'))->where('cpc.product_id = ?', $productId)->where('cc.site_id = ?', $siteId)->where('cc1.site_id = ?', $siteId)->where('ccd.language_id = ?', $languageId)->where("ch.key_type = 'c'")->order(array('cpc.category_id', 'cpc.product_id', 'cc1.lvl'))->fetchAll();
 }