コード例 #1
0
 function it_normalizes_a_root_category(CategoryInterface $category)
 {
     $category->getCode()->willReturn('foo');
     $category->getParent()->willReturn(null);
     $this->normalize($category, 'json')->shouldReturn(['code' => 'foo']);
 }
コード例 #2
0
 /**
  * Get new normalized categories.
  *
  * @param CategoryInterface $category
  * @param array             $context
  *
  * @return array
  *
  * @throws CategoryNotMappedException
  */
 protected function getNormalizedNewCategory(CategoryInterface $category, array $context)
 {
     $parentCategoryId = $this->categoryMappingManager->getIdFromCategory($category->getParent(), $context['prestashopUrl'], $context['categoryMapping']);
     $prestashopCategoryBaseParameters = ['name' => $this->getCategoryLabel($category, $context['defaultLocale']), 'is_active' => 1, 'include_in_menu' => 1, 'available_sort_by' => 1, 'default_sort_by' => 1];
     if (false === $context['urlKey']) {
         $prestashopCategoryBaseParameters['url_key'] = $this->generateUrlKey($category, $context['defaultLocale']);
     }
     if (null === $parentCategoryId) {
         throw new CategoryNotMappedException(sprintf('An error occured during the root category creation on Prestashop. The Prestashop ' . 'connector was unable to find the mapped category "%s (%s)". Remember that you need to map your ' . 'Prestashop root categories to Akeneo categories. All sub categories of %s will not be exported.', $category->getLabel(), $category->getCode(), $category->getCode()));
     } else {
         return ['prestashopCategory' => [(string) $parentCategoryId, $prestashopCategoryBaseParameters, $context['defaultStoreView']], 'pimCategory' => $category];
     }
 }