Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
magento2-base
dev
tests
integration
testsuite
Magento
CatalogUrlRewrite
Fixtures
product_custom_url_key.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
use
Magento\Catalog\Api\ProductRepositoryInterface
;
9
use
Magento\Catalog\Model\Category
;
10
use
Magento\Framework\Registry
;
11
use
Magento\TestFramework\Helper\Bootstrap
;
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'
);
26
$product
=
$productRepository
->save(
$product
);
27
$linkManagement
->assignProductToCategories(
$product
->getSku(), [Category::TREE_ROOT_ID,
$category
->getEntityId()]);
28
29
$registry
->unregister(
'isSecureArea'
);
30
$registry
->register(
'isSecureArea'
,
false
);
$category
$category
Definition:
catalog_category_with_slash.php:7
$registry
$registry
Definition:
product_custom_url_key.php:16
$product
$product
Definition:
product_custom_url_key.php:26
Magento\TestFramework\Helper\Bootstrap
Definition:
Bootstrap.php:12
__DIR__
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition:
_bootstrap.php:60
$objectManager
$objectManager
Definition:
product_custom_url_key.php:13
$productRepository
$productRepository
Definition:
product_custom_url_key.php:23
Magento\Catalog\Api\ProductRepositoryInterface
Definition:
ProductRepositoryInterface.php:14
Magento\Catalog\Model\Category
Definition:
DataProviderTest.php:6
$linkManagement
$linkManagement
Definition:
product_with_category.php:81
Magento\Framework\Registry
Definition:
Registry.php:18