Ejemplo n.º 1
0
 /**
  * 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() . ")");
 }
Ejemplo n.º 2
0
 /**
  * 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);
 }
Ejemplo n.º 3
0
 /**
  * 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);
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * 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' : '';
 }
Ejemplo n.º 5
0
 /**
  * Get default options
  *
  * @return array
  */
 protected function getDefaultOptions()
 {
     return \XLite\Model\Category::getAllowedUseClasses();
 }
Ejemplo n.º 6
0
 /**
  * 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;
 }
Ejemplo n.º 7
0
 /**
  * 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);
         }
     }
 }
Ejemplo n.º 8
0
 /**
  * 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);
     }
 }
Ejemplo n.º 9
0
 /**
  * {@inheritDoc}
  */
 public function prepareEntityBeforeCommit($type)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareEntityBeforeCommit', array($type));
     return parent::prepareEntityBeforeCommit($type);
 }
Ejemplo n.º 10
0
 /**
  * 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);
 }
Ejemplo n.º 11
0
 /**
  * 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));
 }
Ejemplo n.º 12
0
 /**
  * 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()));
 }