/** * Match the opened page to a category * * @param \XLite\Model\Category $category Category * * @return void * @access protected * @since 1.0.0 */ protected function doCategoryPageTesting(\XLite\Model\Category $category) { // Title $titleSelector = "h1#page-title.title"; if ($category->getShowTitle()) { $this->assertElementPresent("css={$titleSelector}", "A category title is missing (" . $category->getCategoryId() . ")"); $title = $this->getJSExpression("jQuery('{$titleSelector}').html()"); $this->assertEquals($category->getName(), $title, "A category displays a wrong title (" . $category->getCategoryId() . ")"); } else { $this->assertElementNotPresent("css={$titleSelector}", "A category title is exists (" . $category->getCategoryId() . ")"); } // Description $method = $category->getDescription() ? "assertElementPresent" : "assertElementNotPresent"; $this->{$method}("css=.category-description", "Wrong category description ({$method}, " . $category->getCategoryId() . ")"); }
/** * Constructor * * @param array $data Entity properties OPTIONAL * * @return void */ public function __construct(array $data = array()) { $this->featuredProducts = new \Doctrine\Common\Collections\ArrayCollection(); parent::__construct($data); }
/** * Import 'image' value * * @param \XLite\Model\Category $model Category * @param string $value Value * @param array $column Column info * * @return void */ protected function importImageColumn(\XLite\Model\Category $model, $value, array $column) { if ($value && $this->verifyValueAsFile($value)) { $image = $model->getImage(); if (!$image) { $image = new \XLite\Model\Image\Category\Image(); $image->setCategory($model); $model->setImage($image); \XLite\Core\Database::getEM()->persist($image); } if (1 < count(parse_url($value))) { $success = $image->loadFromURL($value, true); } else { $dir = \Includes\Utils\FileManager::getRealPath(LC_DIR_VAR . $this->importer->getOptions()->dir); $success = $image->loadFromLocalFile($dir . LC_DS . $value); } if (!$success) { $this->addError('PRODUCT-IMG-LOAD-FAILED', array('column' => $column, 'value' => $path)); } else { $image->setNeedProcess(1); } } }
/** * Assemble list item link class name * * @param integer $i Item number * @param integer $count Items count * @param \XLite\Model\Category $category Current category * * @return string */ protected function assembleLinkClassName($i, $count, \XLite\Model\Category $category) { return \XLite\Core\Request::getInstance()->category_id == $category->getCategoryId() ? 'active' : ''; }
/** * Get default options * * @return array */ protected function getDefaultOptions() { return \XLite\Model\Category::getAllowedUseClasses(); }
/** * Prepare subnodes for the location path node * * @param \XLite\Model\Category $category Node category * * @return array */ protected function getLocationNodeSubnodes(\XLite\Model\Category $category) { $nodes = array(); foreach ($category->getSiblings(true) as $category) { $nodes[] = \XLite\View\Location\Node::create($category->getName(), $this->getCategoryURL($category)); } return $nodes; }
/** * Import 'image' value * * @param \XLite\Model\Category $model Category * @param string $value Value * @param array $column Column info * * @return void */ protected function importImageColumn(\XLite\Model\Category $model, $value, array $column) { if ($value && $this->verifyValueAsFile($value)) { $image = $model->getImage(); if (!$image) { $image = new \XLite\Model\Image\Category\Image(); $image->setCategory($model); $model->setImage($image); \XLite\Core\Database::getEM()->persist($image); } if (1 < count(parse_url($value))) { $image->loadFromURL($value, true); } else { $dir = \Includes\Utils\FileManager::getRealPath(LC_DIR_VAR . $this->importer->getOptions()->dir); $image->loadFromLocalFile($dir . LC_DS . $value); } } }
/** * Update quick flags for a category * * @param \XLite\Model\Category $entity Category * @param array $flags Flags to set * * @return void */ protected function updateQuickFlags(\XLite\Model\Category $entity, array $flags) { $quickFlags = $entity->getQuickFlags(); if (!isset($quickFlags)) { $quickFlags = new \XLite\Model\Category\QuickFlags(); $quickFlags->setCategory($entity); $entity->setQuickFlags($quickFlags); } foreach ($flags as $name => $delta) { $name = \Includes\Utils\Converter::convertToPascalCase($name); $quickFlags->{'set' . $name}($quickFlags->{'get' . $name}() + $delta); } }
/** * {@inheritDoc} */ public function prepareEntityBeforeCommit($type) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareEntityBeforeCommit', array($type)); return parent::prepareEntityBeforeCommit($type); }
/** * Import 'openGraphMeta' value * * @param \XLite\Model\Category $model Category * @param mixed $value Value * @param array $column Column info * * @return void */ protected function importOpenGraphMetaColumn(\XLite\Model\Category $model, $value, array $column) { if (!$model->getUseCustomOG()) { $value = $model->getOpenGraphMetaTags(false); } elseif (is_array($value)) { $value = implode(PHP_EOL, $value); } $model->setOgMeta($value); }
/** * Assemble category data * * @param \XLite\Model\Category $category Category * * @return array */ protected function assembleCategoryData(\XLite\Model\Category $category) { return array('loc' => array('target' => 'category', 'category_id' => $category->getCategoryId()), 'lastmod' => \XLite\Core\Converter::time(), 'changefreq' => \XLite\Core\Config::getInstance()->CDev->XMLSitemap->category_changefreq, 'priority' => $this->processPriority(\XLite\Core\Config::getInstance()->CDev->XMLSitemap->category_priority)); }
/** * Check if the category is visible on the storefront for the current customer * * @param \XLite\Model\Category $current Current category * * @return boolean */ protected function checkStorefrontVisibility($current) { return $current->getEnabled() && (0 === $current->getMemberships()->count() || in_array(\XLite\Core\Auth::getInstance()->getMembershipId(), $current->getMembershipIds())); }