Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
product_custom_url_key.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
12 
13 $objectManager = Bootstrap::getObjectManager();
14 
16 $registry = $objectManager->get(Registry::class);
17 $registry->unregister('isSecureArea');
18 $registry->register('isSecureArea', true);
19 
20 require __DIR__ . '/../_files/product_with_category.php';
21 
23 $productRepository = $objectManager->get(ProductRepositoryInterface::class);
24 $product->setStoreId(1);
25 $product->setUrlKey('store-1-key');
27 $linkManagement->assignProductToCategories($product->getSku(), [Category::TREE_ROOT_ID, $category->getEntityId()]);
28 
29 $registry->unregister('isSecureArea');
30 $registry->register('isSecureArea', false);
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60