How to set the category ids to a products from category path?get product category pathEdit products from certain categoryHow do I set new product's category?Filter Category Collection by Enabled, Visible ProductsInclude Category Path in SitemapMagento2: Assign products to category programaticallyMagento2: Remove Category path from product URL is not workingMagento 2 : Backend Products in CategoryHow to edit category in Magento 1 using PHP using path (Not ID)Magento2: Remove Category path from product URL is not working for all productsHow to add category Path when creating product progrmatically in magento 2
Why Shazam when there is already Superman?
Can I say "fingers" when referring to toes?
What is Cash Advance APR?
PTIJ: Haman's bad computer
Recommended PCB layout understanding - ADM2572 datasheet
Is there a RAID 0 Equivalent for RAM?
Why does the Sun have different day lengths, but not the gas giants?
How could a planet have erratic days?
What exactly color does ozone gas have?
How much character growth crosses the line into breaking the character
Why should universal income be universal?
What is the evidence for the "tyranny of the majority problem" in a direct democracy context?
Yosemite Fire Rings - What to Expect?
Why is the "ls" command showing permissions of files in a FAT32 partition?
How should I respond when I lied about my education and the company finds out through background check?
Calculating total slots
Is this toilet slogan correct usage of the English language?
How to explain what's wrong with this application of the chain rule?
Bridge building with irregular planks
How can I avoid dust and bubbles when installing window film?
What is going on with 'gets(stdin)' on the site coderbyte?
Using substitution ciphers to generate new alphabets in a novel
What does "Scientists rise up against statistical significance" mean? (Comment in Nature)
Does Doodling or Improvising on the Piano Have Any Benefits?
How to set the category ids to a products from category path?
get product category pathEdit products from certain categoryHow do I set new product's category?Filter Category Collection by Enabled, Visible ProductsInclude Category Path in SitemapMagento2: Assign products to category programaticallyMagento2: Remove Category path from product URL is not workingMagento 2 : Backend Products in CategoryHow to edit category in Magento 1 using PHP using path (Not ID)Magento2: Remove Category path from product URL is not working for all productsHow to add category Path when creating product progrmatically in magento 2
I want to progrmmatically create products from a xml.
Ex : I am getting the product categories as like below.
Default Category/Beer ,
Default Category/Beer /CRAFT,
Default Category/Beer /CRAFT/BOMBER BEER,
Default Category/BEER,
Default Category for Store 2/Beer ,
Default Category for Store 2/Beer /CRAFT,
Default Category for Store 2/Beer /CRAFT/BOMBER BEER,
Default Category for Store 2/BEERe
I am getting the category path from the xml.I want to assign the category to the product.How can i assign the categories to the product?
product magento2.2 custom programmatically
add a comment |
I want to progrmmatically create products from a xml.
Ex : I am getting the product categories as like below.
Default Category/Beer ,
Default Category/Beer /CRAFT,
Default Category/Beer /CRAFT/BOMBER BEER,
Default Category/BEER,
Default Category for Store 2/Beer ,
Default Category for Store 2/Beer /CRAFT,
Default Category for Store 2/Beer /CRAFT/BOMBER BEER,
Default Category for Store 2/BEERe
I am getting the category path from the xml.I want to assign the category to the product.How can i assign the categories to the product?
product magento2.2 custom programmatically
add a comment |
I want to progrmmatically create products from a xml.
Ex : I am getting the product categories as like below.
Default Category/Beer ,
Default Category/Beer /CRAFT,
Default Category/Beer /CRAFT/BOMBER BEER,
Default Category/BEER,
Default Category for Store 2/Beer ,
Default Category for Store 2/Beer /CRAFT,
Default Category for Store 2/Beer /CRAFT/BOMBER BEER,
Default Category for Store 2/BEERe
I am getting the category path from the xml.I want to assign the category to the product.How can i assign the categories to the product?
product magento2.2 custom programmatically
I want to progrmmatically create products from a xml.
Ex : I am getting the product categories as like below.
Default Category/Beer ,
Default Category/Beer /CRAFT,
Default Category/Beer /CRAFT/BOMBER BEER,
Default Category/BEER,
Default Category for Store 2/Beer ,
Default Category for Store 2/Beer /CRAFT,
Default Category for Store 2/Beer /CRAFT/BOMBER BEER,
Default Category for Store 2/BEERe
I am getting the category path from the xml.I want to assign the category to the product.How can i assign the categories to the product?
product magento2.2 custom programmatically
product magento2.2 custom programmatically
edited yesterday
Mujahidh
asked yesterday
MujahidhMujahidh
1,41412036
1,41412036
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
As per given text you cannot find category id.
You can achieve this function using below code.
You need to create category id and category name array. by mapping category name you will get category id, after set category id to products.
protected $_categoryCollectionFactory;
public function __construct(
MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory
)
$this->_categoryCollectionFactory = $categoryCollectionFactory;
public function getCategoryIds()
$collection = $this->_categoryCollectionFactory->create();
$allCategory = array();
foreach($collection as $category)
$allCategory[$category->getName()] = $category->getId() ;
return $allCategory;
thanks, I want to get the category from category path and assign the category to the products
– Mujahidh
yesterday
Yes you can get last string from path so you will get category name, using this rray you will find category id
– Prashant Valanda
yesterday
where can i pass the path as an argument here?
– Mujahidh
17 hours ago
You do not need to pass any argument, first find category name and call $array = $thi->getCategoryIds() funcll give you all category name and category id array.$array['category name here']using this code you will get category id
– Prashant Valanda
9 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266825%2fhow-to-set-the-category-ids-to-a-products-from-category-path%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As per given text you cannot find category id.
You can achieve this function using below code.
You need to create category id and category name array. by mapping category name you will get category id, after set category id to products.
protected $_categoryCollectionFactory;
public function __construct(
MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory
)
$this->_categoryCollectionFactory = $categoryCollectionFactory;
public function getCategoryIds()
$collection = $this->_categoryCollectionFactory->create();
$allCategory = array();
foreach($collection as $category)
$allCategory[$category->getName()] = $category->getId() ;
return $allCategory;
thanks, I want to get the category from category path and assign the category to the products
– Mujahidh
yesterday
Yes you can get last string from path so you will get category name, using this rray you will find category id
– Prashant Valanda
yesterday
where can i pass the path as an argument here?
– Mujahidh
17 hours ago
You do not need to pass any argument, first find category name and call $array = $thi->getCategoryIds() funcll give you all category name and category id array.$array['category name here']using this code you will get category id
– Prashant Valanda
9 hours ago
add a comment |
As per given text you cannot find category id.
You can achieve this function using below code.
You need to create category id and category name array. by mapping category name you will get category id, after set category id to products.
protected $_categoryCollectionFactory;
public function __construct(
MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory
)
$this->_categoryCollectionFactory = $categoryCollectionFactory;
public function getCategoryIds()
$collection = $this->_categoryCollectionFactory->create();
$allCategory = array();
foreach($collection as $category)
$allCategory[$category->getName()] = $category->getId() ;
return $allCategory;
thanks, I want to get the category from category path and assign the category to the products
– Mujahidh
yesterday
Yes you can get last string from path so you will get category name, using this rray you will find category id
– Prashant Valanda
yesterday
where can i pass the path as an argument here?
– Mujahidh
17 hours ago
You do not need to pass any argument, first find category name and call $array = $thi->getCategoryIds() funcll give you all category name and category id array.$array['category name here']using this code you will get category id
– Prashant Valanda
9 hours ago
add a comment |
As per given text you cannot find category id.
You can achieve this function using below code.
You need to create category id and category name array. by mapping category name you will get category id, after set category id to products.
protected $_categoryCollectionFactory;
public function __construct(
MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory
)
$this->_categoryCollectionFactory = $categoryCollectionFactory;
public function getCategoryIds()
$collection = $this->_categoryCollectionFactory->create();
$allCategory = array();
foreach($collection as $category)
$allCategory[$category->getName()] = $category->getId() ;
return $allCategory;
As per given text you cannot find category id.
You can achieve this function using below code.
You need to create category id and category name array. by mapping category name you will get category id, after set category id to products.
protected $_categoryCollectionFactory;
public function __construct(
MagentoCatalogModelResourceModelCategoryCollectionFactory $categoryCollectionFactory
)
$this->_categoryCollectionFactory = $categoryCollectionFactory;
public function getCategoryIds()
$collection = $this->_categoryCollectionFactory->create();
$allCategory = array();
foreach($collection as $category)
$allCategory[$category->getName()] = $category->getId() ;
return $allCategory;
answered yesterday
Prashant ValandaPrashant Valanda
9,83412355
9,83412355
thanks, I want to get the category from category path and assign the category to the products
– Mujahidh
yesterday
Yes you can get last string from path so you will get category name, using this rray you will find category id
– Prashant Valanda
yesterday
where can i pass the path as an argument here?
– Mujahidh
17 hours ago
You do not need to pass any argument, first find category name and call $array = $thi->getCategoryIds() funcll give you all category name and category id array.$array['category name here']using this code you will get category id
– Prashant Valanda
9 hours ago
add a comment |
thanks, I want to get the category from category path and assign the category to the products
– Mujahidh
yesterday
Yes you can get last string from path so you will get category name, using this rray you will find category id
– Prashant Valanda
yesterday
where can i pass the path as an argument here?
– Mujahidh
17 hours ago
You do not need to pass any argument, first find category name and call $array = $thi->getCategoryIds() funcll give you all category name and category id array.$array['category name here']using this code you will get category id
– Prashant Valanda
9 hours ago
thanks, I want to get the category from category path and assign the category to the products
– Mujahidh
yesterday
thanks, I want to get the category from category path and assign the category to the products
– Mujahidh
yesterday
Yes you can get last string from path so you will get category name, using this rray you will find category id
– Prashant Valanda
yesterday
Yes you can get last string from path so you will get category name, using this rray you will find category id
– Prashant Valanda
yesterday
where can i pass the path as an argument here?
– Mujahidh
17 hours ago
where can i pass the path as an argument here?
– Mujahidh
17 hours ago
You do not need to pass any argument, first find category name and call $array = $thi->getCategoryIds() funcll give you all category name and category id array.
$array['category name here'] using this code you will get category id– Prashant Valanda
9 hours ago
You do not need to pass any argument, first find category name and call $array = $thi->getCategoryIds() funcll give you all category name and category id array.
$array['category name here'] using this code you will get category id– Prashant Valanda
9 hours ago
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266825%2fhow-to-set-the-category-ids-to-a-products-from-category-path%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown