/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
if (!$this->isEnabled()) {
return;
}
$shop = $this->getReference('shop');
foreach (self::$samples as $hierarchy => $name) {
$category = new Category();
$category->setEnabled(true);
$category->setHierarchy($hierarchy);
$category->setParent(null);
$category->setProducts(new ArrayCollection());
$category->setChildren(new ArrayCollection());
$category->setChildrenCount(0);
$category->setProductsCount(0);
$category->addShop($shop);
$category->translate($this->container->getParameter('locale'))->setName($name);
$category->translate($this->container->getParameter('locale'))->setSlug(Sluggable::makeSlug($name));
$category->translate($this->container->getParameter('locale'))->setShortDescription('');
$category->translate($this->container->getParameter('locale'))->setDescription('');
$category->mergeNewTranslations();
$manager->persist($category);
$this->setReference('category_' . $name, $category);
}
$manager->flush();
}