/** * Return list of product labels * * @param \XLite\Model\Product $product The product to look for * * @return array */ protected function getLabels(\XLite\Model\Product $product) { $labels = parent::getLabels($product); if ($this->isShowMarketPrice($product)) { $labels += \XLite\Module\CDev\MarketPrice\Main::getLabels($product); } return $labels; }
/** * Register JS files * * @return array */ public function getJSFiles() { $list = parent::getJSFiles(); if (\XLite\Core\Config::getInstance()->CDev->Catalog->disable_checkout) { $list[] = 'modules/CDev/Catalog/disable_dragging.js'; } return $list; }
/** * Return product labels * * @param \XLite\Model\Product $product The product to look for * * @return array */ protected function getLabels(\XLite\Model\Product $product) { $labels = parent::getLabels($product); if ($product->isRestrictedProduct()) { $labels = array_reverse($labels); $labels['restricted'] = static::t('Restricted'); $labels = array_reverse($labels); } return $labels; }
/** * Check - show Add to cart button or not * * @param \XLite\Model\Product $product Product * * @return boolean */ protected function isShowAdd2Cart(\XLite\Model\Product $product) { $result = parent::isShowAdd2Cart($product); // FIXME[INVENTORY_TRACKING]: check this later /*if ( $result && $this->xlite->get('InventoryTrackingEnabled') && $product->getComplex('inventory.found') && !$product->get('tracking') ) { $result = 0 < $product->getComplex('inventory.amount'); }*/ return $result; }
/** * Initialize widget (set attributes) * * @param array $params Widget params * * @return void */ public function setWidgetParams(array $params) { parent::setWidgetParams($params); if (!isset($params[static::PARAM_ICON_MAX_WIDTH]) && !isset($params[static::PARAM_ICON_MAX_HEIGHT]) && 0 == $this->getParam(static::PARAM_ICON_MAX_WIDTH) && 0 == $this->getParam(static::PARAM_ICON_MAX_HEIGHT)) { $key = \XLite\View\ItemsList\Product\Customer\ACustomer::WIDGET_TYPE_CENTER . '.' . \XLite\View\ItemsList\Product\Customer\ACustomer::DISPLAY_MODE_GRID; $sizes = \XLite\View\ItemsList\Product\Customer\ACustomer::getIconSizes(); $size = isset($sizes[$key]) ? $sizes[$key] : $sizes['other']; $this->widgetParams[static::PARAM_ICON_MAX_WIDTH]->setValue($size[0]); $this->widgetParams[static::PARAM_ICON_MAX_HEIGHT]->setValue($size[1]); } }
/** * Register the CSS classes for this block * * @return string */ protected function getBlockClasses() { return parent::getBlockClasses() . ' block-coming-soon'; }
/** * Return product labels * * @param \XLite\Model\Product $product The product to look for * * @return array */ protected function getLabels(\XLite\Model\Product $product) { $labels = parent::getLabels($product); $targets = array(\XLite\Module\CDev\ProductAdvisor\View\ANewArrivals::WIDGET_TARGET_NEW_ARRIVALS, \XLite\Module\CDev\ProductAdvisor\View\AComingSoon::WIDGET_TARGET_COMING_SOON); if (!in_array(static::getWidgetTarget(), $targets)) { // Add ProductAdvisor's labels into the begin of labels list $labels = array_reverse($labels); $labels += \XLite\Module\CDev\ProductAdvisor\Main::getLabels($product); $labels = array_reverse($labels); } return $labels; }
/** * Get cache parameters * * @return array */ protected function getCacheParameters() { $list = parent::getCacheParameters(); $result = array(); $profile = \XLite\Core\Auth::getInstance()->getProfile(); $products = $this->getPageData(); // Gather reviews and ratings data for each product foreach ($products as $product) { $result[] = array($product->getProductId(), $product->getAverageRating(), $product->getVotesCount(), $product->getReviewsCount(), $product->isRatedByUser($profile)); } $list[] = md5(serialize($result)); return $list; }
/** * getDefaultOptions * * @return array */ protected function getDefaultOptions() { return \XLite\View\ItemsList\Product\Customer\ACustomer::getCenterDisplayModes(); }
/** * Return params list to use for search * TODO refactor * * @return \XLite\Core\CommonCell */ protected function getSearchCondition() { $result = parent::getSearchCondition(); foreach (\XLite\View\ItemsList\Product\Customer\Search::getSearchParams() as $modelParam => $requestParam) { $paramValue = $this->getParam($requestParam); if ('' !== $paramValue && 0 !== $paramValue) { $result->{$modelParam} = $paramValue; } } return $result; }
/** * Initialize widget (set attributes) * * @param array $params Widget params * * @return void */ public function setWidgetParams(array $params) { parent::setWidgetParams($params); unset($this->widgetParams[self::PARAM_SHOW_SORT_BY_SELECTOR]); }
/** * Get a list of JavaScript files * * @return array */ public function getJSFiles() { $list = parent::getJSFiles(); $list[] = 'modules/XC/NextPreviousProduct/items-list/cookie-setter.js'; return $list; }
/** * Unset 'pageId' value from saved parameters * * @param string $param Parameter name * * @return mixed */ protected function getSavedRequestParam($param) { return \XLite\View\Pager\APager::PARAM_PAGE_ID != $param ? parent::getSavedRequestParam($param) : null; }
/** * Register the CSS classes for this block * * @return string */ protected function getBlockClasses() { return parent::getBlockClasses() . ' block-bestsellers'; }
/** * Return product labels * * @param \XLite\Model\Product $product The product to look for * * @return array */ protected function getLabels(\XLite\Model\Product $product) { return parent::getLabels($product) + \XLite\Module\XC\FreeShipping\Core\Labels::getLabel($product); }
/** * Register the CSS classes for this block * * @return string */ protected function getBlockClasses() { return parent::getBlockClasses() . ' block-new-arrivals'; }
/** * Check if widget is visible * * @return boolean */ protected function isVisible() { return parent::isVisible() && $this->getCategory() && $this->getCategory()->isVisible(); }
/** * Get cache parameters * * @return array */ protected function getCacheParameters() { $list = parent::getCacheParameters(); $list[] = $this->getCategoryId(); return $list; }
/** * Add CSS style to items list * * @return string */ public function getListCSSClasses() { return parent::getListCSSClasses() . ' add-to-cart-popup'; }
/** * Check if widget is visible * * @return boolean */ protected function isVisible() { $result = parent::isVisible(); if (!\XLite\Core\CMSConnector::isCMSStarted() && !$this->isAJAX()) { if (self::WIDGET_TYPE_SIDEBAR == $this->getParam(self::PARAM_WIDGET_TYPE)) { $result = $result && 'sidebar.first' == $this->viewListName; } else { $result = $result && 'center.bottom' == $this->viewListName; } } return $result; }
/** * Get products 'sort by' fields * * @return array */ protected function getSortByFields() { $fields = parent::getSortByFields(); $fields += array('bought' => static::SORT_BY_MODE_BOUGHT); return $fields; }
/** * Add "LC widget settings" fieldset for the form * * :FIXME: to revize * * @param array &$form Form description * @param string $class LC widget class * @param string $label Widget class readable name * @param array $block Block description OPTIONAL * @param array $formInput Form input OPTIONAL * * @return void */ protected function addSettingsFieldset(array &$form, $class, $label, array $block = array(), array $formInput = array()) { // Get settings from LC $widget = $this->getHandler()->getWidget($class); if (isset($block['options']) && is_array($block['options'])) { $widget->setWidgetParams($block['options']); } // To prevent some unpredictable errors related to backslashes in element IDs $key = $this->getBlockName($class); if ($formInput && isset($formInput['lc_widget']) && isset($formInput['lc_widget'][$key])) { $widget->setWidgetParams($formInput['lc_widget'][$key]); } $settings = $widget->getWidgetSettings(); if ($settings) { $form[$key] = array('#type' => 'fieldset', '#title' => 'Parameters', '#attributes' => array('id' => $key)); $extendedItemsList = is_subclass_of($widget->getProtectedWidget(), 'XLite\\View\\ItemsList\\Product\\Customer\\ACustomer'); // Translate native LC options into Drupal format foreach ($settings as $name => $param) { $form[$key][$name] = array('#type' => $this->fieldTypesTranslationTable[$param->type], '#title' => t($param->label), '#default_value' => isset($block['options'][$name]) ? $block['options'][$name] : $param->value); $extendedAttributes = array(\XLite\View\ItemsList\Product\Customer\ACustomer::PARAM_ICON_MAX_WIDTH, \XLite\View\ItemsList\Product\Customer\ACustomer::PARAM_ICON_MAX_HEIGHT); if ('select' === $form[$key][$name]['#type']) { $form[$key][$name]['#options'] = $param->options; } elseif ($extendedItemsList && in_array($name, $extendedAttributes)) { $form[$key][$name]['#description'] = t('recommended: !size', array('!size' => 110)); } } if ($extendedItemsList) { if (!isset($form['#attached'])) { $form['#attached'] = array('js' => array()); } elseif (!isset($form['#attached']['js'])) { $form['#attached']['js'] = array(); } $path = \XLite\Core\Layout::getInstance()->getResourceFullPath('modules/CDev/DrupalConnector/blocks.js', \XLite::CUSTOMER_INTERFACE); $form['#attached']['js'][] = \XLite\View\AView::modifyResourcePath($path); // Display modes data $jsData = array(\XLite\View\ItemsList\Product\Customer\ACustomer::WIDGET_TYPE_SIDEBAR => \XLite\View\ItemsList\Product\Customer\ACustomer::getSidebarDisplayModes(), \XLite\View\ItemsList\Product\Customer\ACustomer::WIDGET_TYPE_CENTER => \XLite\View\ItemsList\Product\Customer\ACustomer::getCenterDisplayModes()); drupal_add_js('lcConnectorBlocks.' . $key . ' = ' . json_encode($jsData) . ';', 'inline'); // Recommended icons sizes $jsData = \XLite\View\ItemsList\Product\Customer\ACustomer::getIconSizes(); $lbl = t('recommended: !size'); drupal_add_js('lcConnectorRecommendedIconSizes.' . $key . ' = ' . json_encode($jsData) . ';' . PHP_EOL . 'var lcConnectorRecommendedLabel = \'' . $lbl . '\';', 'inline'); } } }
/** * Returns CSS classes for the container element * * @return string */ public function getListCSSClasses() { return parent::getListCSSClasses() . ' upselling-products'; }
/** * Register the CSS classes for this block * * @return string */ protected function getBlockClasses() { return parent::getBlockClasses() . ' block-bought'; }
/** * Return product labels * * @param \XLite\Model\Product $product The product to look for * * @return array */ protected function getLabels(\XLite\Model\Product $product) { return parent::getLabels($product) + \XLite\Module\CDev\Sale\Core\Labels::getLabel($product); }
/** * getPageData * * @return array */ protected function getPageData() { return $this->getOnlyEntities(parent::getPageData()); }
/** * Register the CSS classes for this block * * @return string */ protected function getBlockClasses() { return parent::getBlockClasses() . ' block-recently-viewed'; }