Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DuplicateCategory extends MagentoBackendAppAction {
- protected $_categoryFactory;
- public function __construct(
- MagentoBackendAppActionContext $context,
- MagentoCatalogModelCategoryFactory $categoryFactory
- ) {
- parent::__construct($context);
- $this->_categoryFactory = $categoryFactory;
- }
- $parentCategoryObj = $this->_categoryFactory->create()->load(2);
- $duplicateCategoryObj = $this->_categoryFactory->create()->load(8);
- $catagoryObject = $this->_categoryFactory->create();
- $categoryName = $duplicateCategoryObj->getName();
- $categoryUrlKey = strtolower($this->getCategoryUrlKey($categoryName));
- $catagoryObject->setPath($parentCategoryObj->getPath())
- ->setParentId($parentCategory)
- ->setName($duplicateCategoryObj->getName())
- ->setUrlKey($categoryUrlKey)
- ->setStoreId($storeId)
- ->setIsActive(true);
- $catagoryObject->save();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement