removing categorty in product page is giving errorMagento2: Could not save product “330664” with position 0 to category 3567Magento 2.2.4: Could not save product “3395” with position 1 to category 1882Magento 2 Cannot save product (Invalid option value)Get product number in categoryMagento 2: How to Set Bulk Product Position in Category?Magento reindexingMageto2 product listing page random productJS error on product page Cannot read property '' of undefined _getAttributeCodeById which doesnt allow to load configrable price and imageProduct category update issue in magento2Magento 2.2.3 CE unable to add/remove item from wishlist?Magento 2 breadcrumbs issue on product view page?Magento 2.2.4: Could not save product “3395” with position 1 to category 1882
How to fry ground beef so it is well-browned
Why did some of my point & shoot film photos come back with one third light white or orange?
Elements that can bond to themselves?
How exactly does Hawking radiation decrease the mass of black holes?
How come there are so many candidates for the 2020 Democratic party presidential nomination?
Read line from file and process something
Random Forest different results for same observation
Why didn't the Space Shuttle bounce back into space as many times as possible so as to lose a lot of kinetic energy up there?
How much cash can I safely carry into the USA and avoid civil forfeiture?
Could the terminal length of components like resistors be reduced?
How to limit Drive Letters Windows assigns to new removable USB drives
What is the most expensive material in the world that could be used to create Pun-Pun's lute?
Thesis on avalanche prediction using One Class SVM
'It addicted me, with one taste.' Can 'addict' be used transitively?
What happened to Captain America in Endgame?
Why do games have consumables?
Pulling the rope with one hand is as heavy as with two hands?
Don’t seats that recline flat defeat the purpose of having seatbelts?
Can someone publish a story that happened to you?
Why does nature favour the Laplacian?
Solving a quadratic equation by completing the square
What makes accurate emulation of old systems a difficult task?
What happens in the secondary winding if there's no spark plug connected?
Is Diceware more secure than a long passphrase?
removing categorty in product page is giving error
Magento2: Could not save product “330664” with position 0 to category 3567Magento 2.2.4: Could not save product “3395” with position 1 to category 1882Magento 2 Cannot save product (Invalid option value)Get product number in categoryMagento 2: How to Set Bulk Product Position in Category?Magento reindexingMageto2 product listing page random productJS error on product page Cannot read property '' of undefined _getAttributeCodeById which doesnt allow to load configrable price and imageProduct category update issue in magento2Magento 2.2.3 CE unable to add/remove item from wishlist?Magento 2 breadcrumbs issue on product view page?Magento 2.2.4: Could not save product “3395” with position 1 to category 1882
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
We are facing issues - https://prnt.sc/mgdybf why we are not able to remove the Deal and Pre Owned category.
Could not save product "26652" with position 0 to category 435
What is this error message about? How to solve this issue?
Regards
Rachna
magento2 product category indexing
add a comment |
We are facing issues - https://prnt.sc/mgdybf why we are not able to remove the Deal and Pre Owned category.
Could not save product "26652" with position 0 to category 435
What is this error message about? How to solve this issue?
Regards
Rachna
magento2 product category indexing
add a comment |
We are facing issues - https://prnt.sc/mgdybf why we are not able to remove the Deal and Pre Owned category.
Could not save product "26652" with position 0 to category 435
What is this error message about? How to solve this issue?
Regards
Rachna
magento2 product category indexing
We are facing issues - https://prnt.sc/mgdybf why we are not able to remove the Deal and Pre Owned category.
Could not save product "26652" with position 0 to category 435
What is this error message about? How to solve this issue?
Regards
Rachna
magento2 product category indexing
magento2 product category indexing
asked Feb 7 at 13:13
Rachna ThakurRachna Thakur
385
385
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Update
Some people have faced this issue already and have a solution. Check these posts
Magento2: Could not save product "330664" with position 0 to category 3567
https://github.com/magento/magento2/issues/8970
The error is from the CategoryLinkRepository File from module-catalog which handles the save functionality. Check your exception log for more details, which tells you exactly why you couldn't save the product. Hope am pointing you to the right direction. Check also deleteByIds method, it can be the potential cause of this issue.
/**
* @inheritdoc
*/
public function deleteByIds($categoryId, $sku)
$category = $this->categoryRepository->get($categoryId);
$product = $this->productRepository->get($sku);
$productPositions = $category->getProductsPosition();
$productID = $product->getId();
if (!isset($productPositions[$productID]))
throw new InputException(__('Category does not contain specified product'));
$backupPosition = $productPositions[$productID];
unset($productPositions[$productID]);
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%product" with position %position to category %category',
[
"product" => $product->getId(),
"position" => $backupPosition,
"category" => $category->getId()
]
),
$e
);
return true;
magentovendormagentomodule-catalogModelCategoryLinkRepository.php
/**
* @inheritdoc
*/
public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
$category = $this->categoryRepository->get($productLink->getCategoryId());
$product = $this->productRepository->get($productLink->getSku());
$productPositions = $category->getProductsPosition();
$productPositions[$product->getId()] = $productLink->getPosition();
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%1" with position %2 to category %3',
$product->getId(),
$productLink->getPosition(),
$category->getId()
),
$e
);
return true;
add a comment |
In my case I put the erorr message within the returned string
vendor/magento/module-catalog/Model/CategoryLinkRepository.php
public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
$category = $this->categoryRepository->get($productLink->getCategoryId());
$product = $this->productRepository->get($productLink->getSku());
$productPositions = $category->getProductsPosition();
$productPositions[$product->getId()] = $productLink->getPosition();
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%1" with position %2 to category %3 : error %4',
$product->getId(),
$productLink->getPosition(),
$category->getId(),
$e->getMessage()
),
$e
);
return true;
The error was about unique integrity in the database.
And sure enough there were duplicate category IDs in an array I was providing for linking products to categories
public function __construct(
MagentoCatalogApiCategoryLinkManagementInterface $categoryLinkManagementInterface
)
$this->categoryLinkManagementInterface = $categoryLinkManagementInterface;
/**
* Assign product to category
* @param MagentoCatalogModelProduct $product
* @param array $categoryIds
* @return void
*/
public function assignProductToCategory($product, $categoryIds = [])
if(!empty($categoryIds))
$this->categoryLinkManagementInterface->assignProductToCategories(
$product->getSku(),
$categoryIds
);
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%2f260866%2fremoving-categorty-in-product-page-is-giving-error%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Update
Some people have faced this issue already and have a solution. Check these posts
Magento2: Could not save product "330664" with position 0 to category 3567
https://github.com/magento/magento2/issues/8970
The error is from the CategoryLinkRepository File from module-catalog which handles the save functionality. Check your exception log for more details, which tells you exactly why you couldn't save the product. Hope am pointing you to the right direction. Check also deleteByIds method, it can be the potential cause of this issue.
/**
* @inheritdoc
*/
public function deleteByIds($categoryId, $sku)
$category = $this->categoryRepository->get($categoryId);
$product = $this->productRepository->get($sku);
$productPositions = $category->getProductsPosition();
$productID = $product->getId();
if (!isset($productPositions[$productID]))
throw new InputException(__('Category does not contain specified product'));
$backupPosition = $productPositions[$productID];
unset($productPositions[$productID]);
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%product" with position %position to category %category',
[
"product" => $product->getId(),
"position" => $backupPosition,
"category" => $category->getId()
]
),
$e
);
return true;
magentovendormagentomodule-catalogModelCategoryLinkRepository.php
/**
* @inheritdoc
*/
public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
$category = $this->categoryRepository->get($productLink->getCategoryId());
$product = $this->productRepository->get($productLink->getSku());
$productPositions = $category->getProductsPosition();
$productPositions[$product->getId()] = $productLink->getPosition();
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%1" with position %2 to category %3',
$product->getId(),
$productLink->getPosition(),
$category->getId()
),
$e
);
return true;
add a comment |
Update
Some people have faced this issue already and have a solution. Check these posts
Magento2: Could not save product "330664" with position 0 to category 3567
https://github.com/magento/magento2/issues/8970
The error is from the CategoryLinkRepository File from module-catalog which handles the save functionality. Check your exception log for more details, which tells you exactly why you couldn't save the product. Hope am pointing you to the right direction. Check also deleteByIds method, it can be the potential cause of this issue.
/**
* @inheritdoc
*/
public function deleteByIds($categoryId, $sku)
$category = $this->categoryRepository->get($categoryId);
$product = $this->productRepository->get($sku);
$productPositions = $category->getProductsPosition();
$productID = $product->getId();
if (!isset($productPositions[$productID]))
throw new InputException(__('Category does not contain specified product'));
$backupPosition = $productPositions[$productID];
unset($productPositions[$productID]);
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%product" with position %position to category %category',
[
"product" => $product->getId(),
"position" => $backupPosition,
"category" => $category->getId()
]
),
$e
);
return true;
magentovendormagentomodule-catalogModelCategoryLinkRepository.php
/**
* @inheritdoc
*/
public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
$category = $this->categoryRepository->get($productLink->getCategoryId());
$product = $this->productRepository->get($productLink->getSku());
$productPositions = $category->getProductsPosition();
$productPositions[$product->getId()] = $productLink->getPosition();
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%1" with position %2 to category %3',
$product->getId(),
$productLink->getPosition(),
$category->getId()
),
$e
);
return true;
add a comment |
Update
Some people have faced this issue already and have a solution. Check these posts
Magento2: Could not save product "330664" with position 0 to category 3567
https://github.com/magento/magento2/issues/8970
The error is from the CategoryLinkRepository File from module-catalog which handles the save functionality. Check your exception log for more details, which tells you exactly why you couldn't save the product. Hope am pointing you to the right direction. Check also deleteByIds method, it can be the potential cause of this issue.
/**
* @inheritdoc
*/
public function deleteByIds($categoryId, $sku)
$category = $this->categoryRepository->get($categoryId);
$product = $this->productRepository->get($sku);
$productPositions = $category->getProductsPosition();
$productID = $product->getId();
if (!isset($productPositions[$productID]))
throw new InputException(__('Category does not contain specified product'));
$backupPosition = $productPositions[$productID];
unset($productPositions[$productID]);
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%product" with position %position to category %category',
[
"product" => $product->getId(),
"position" => $backupPosition,
"category" => $category->getId()
]
),
$e
);
return true;
magentovendormagentomodule-catalogModelCategoryLinkRepository.php
/**
* @inheritdoc
*/
public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
$category = $this->categoryRepository->get($productLink->getCategoryId());
$product = $this->productRepository->get($productLink->getSku());
$productPositions = $category->getProductsPosition();
$productPositions[$product->getId()] = $productLink->getPosition();
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%1" with position %2 to category %3',
$product->getId(),
$productLink->getPosition(),
$category->getId()
),
$e
);
return true;
Update
Some people have faced this issue already and have a solution. Check these posts
Magento2: Could not save product "330664" with position 0 to category 3567
https://github.com/magento/magento2/issues/8970
The error is from the CategoryLinkRepository File from module-catalog which handles the save functionality. Check your exception log for more details, which tells you exactly why you couldn't save the product. Hope am pointing you to the right direction. Check also deleteByIds method, it can be the potential cause of this issue.
/**
* @inheritdoc
*/
public function deleteByIds($categoryId, $sku)
$category = $this->categoryRepository->get($categoryId);
$product = $this->productRepository->get($sku);
$productPositions = $category->getProductsPosition();
$productID = $product->getId();
if (!isset($productPositions[$productID]))
throw new InputException(__('Category does not contain specified product'));
$backupPosition = $productPositions[$productID];
unset($productPositions[$productID]);
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%product" with position %position to category %category',
[
"product" => $product->getId(),
"position" => $backupPosition,
"category" => $category->getId()
]
),
$e
);
return true;
magentovendormagentomodule-catalogModelCategoryLinkRepository.php
/**
* @inheritdoc
*/
public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
$category = $this->categoryRepository->get($productLink->getCategoryId());
$product = $this->productRepository->get($productLink->getSku());
$productPositions = $category->getProductsPosition();
$productPositions[$product->getId()] = $productLink->getPosition();
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%1" with position %2 to category %3',
$product->getId(),
$productLink->getPosition(),
$category->getId()
),
$e
);
return true;
edited Feb 7 at 13:38
answered Feb 7 at 13:33
HaijeromeHaijerome
1,0661119
1,0661119
add a comment |
add a comment |
In my case I put the erorr message within the returned string
vendor/magento/module-catalog/Model/CategoryLinkRepository.php
public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
$category = $this->categoryRepository->get($productLink->getCategoryId());
$product = $this->productRepository->get($productLink->getSku());
$productPositions = $category->getProductsPosition();
$productPositions[$product->getId()] = $productLink->getPosition();
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%1" with position %2 to category %3 : error %4',
$product->getId(),
$productLink->getPosition(),
$category->getId(),
$e->getMessage()
),
$e
);
return true;
The error was about unique integrity in the database.
And sure enough there were duplicate category IDs in an array I was providing for linking products to categories
public function __construct(
MagentoCatalogApiCategoryLinkManagementInterface $categoryLinkManagementInterface
)
$this->categoryLinkManagementInterface = $categoryLinkManagementInterface;
/**
* Assign product to category
* @param MagentoCatalogModelProduct $product
* @param array $categoryIds
* @return void
*/
public function assignProductToCategory($product, $categoryIds = [])
if(!empty($categoryIds))
$this->categoryLinkManagementInterface->assignProductToCategories(
$product->getSku(),
$categoryIds
);
add a comment |
In my case I put the erorr message within the returned string
vendor/magento/module-catalog/Model/CategoryLinkRepository.php
public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
$category = $this->categoryRepository->get($productLink->getCategoryId());
$product = $this->productRepository->get($productLink->getSku());
$productPositions = $category->getProductsPosition();
$productPositions[$product->getId()] = $productLink->getPosition();
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%1" with position %2 to category %3 : error %4',
$product->getId(),
$productLink->getPosition(),
$category->getId(),
$e->getMessage()
),
$e
);
return true;
The error was about unique integrity in the database.
And sure enough there were duplicate category IDs in an array I was providing for linking products to categories
public function __construct(
MagentoCatalogApiCategoryLinkManagementInterface $categoryLinkManagementInterface
)
$this->categoryLinkManagementInterface = $categoryLinkManagementInterface;
/**
* Assign product to category
* @param MagentoCatalogModelProduct $product
* @param array $categoryIds
* @return void
*/
public function assignProductToCategory($product, $categoryIds = [])
if(!empty($categoryIds))
$this->categoryLinkManagementInterface->assignProductToCategories(
$product->getSku(),
$categoryIds
);
add a comment |
In my case I put the erorr message within the returned string
vendor/magento/module-catalog/Model/CategoryLinkRepository.php
public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
$category = $this->categoryRepository->get($productLink->getCategoryId());
$product = $this->productRepository->get($productLink->getSku());
$productPositions = $category->getProductsPosition();
$productPositions[$product->getId()] = $productLink->getPosition();
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%1" with position %2 to category %3 : error %4',
$product->getId(),
$productLink->getPosition(),
$category->getId(),
$e->getMessage()
),
$e
);
return true;
The error was about unique integrity in the database.
And sure enough there were duplicate category IDs in an array I was providing for linking products to categories
public function __construct(
MagentoCatalogApiCategoryLinkManagementInterface $categoryLinkManagementInterface
)
$this->categoryLinkManagementInterface = $categoryLinkManagementInterface;
/**
* Assign product to category
* @param MagentoCatalogModelProduct $product
* @param array $categoryIds
* @return void
*/
public function assignProductToCategory($product, $categoryIds = [])
if(!empty($categoryIds))
$this->categoryLinkManagementInterface->assignProductToCategories(
$product->getSku(),
$categoryIds
);
In my case I put the erorr message within the returned string
vendor/magento/module-catalog/Model/CategoryLinkRepository.php
public function save(MagentoCatalogApiDataCategoryProductLinkInterface $productLink)
$category = $this->categoryRepository->get($productLink->getCategoryId());
$product = $this->productRepository->get($productLink->getSku());
$productPositions = $category->getProductsPosition();
$productPositions[$product->getId()] = $productLink->getPosition();
$category->setPostedProducts($productPositions);
try
$category->save();
catch (Exception $e)
throw new CouldNotSaveException(
__(
'Could not save product "%1" with position %2 to category %3 : error %4',
$product->getId(),
$productLink->getPosition(),
$category->getId(),
$e->getMessage()
),
$e
);
return true;
The error was about unique integrity in the database.
And sure enough there were duplicate category IDs in an array I was providing for linking products to categories
public function __construct(
MagentoCatalogApiCategoryLinkManagementInterface $categoryLinkManagementInterface
)
$this->categoryLinkManagementInterface = $categoryLinkManagementInterface;
/**
* Assign product to category
* @param MagentoCatalogModelProduct $product
* @param array $categoryIds
* @return void
*/
public function assignProductToCategory($product, $categoryIds = [])
if(!empty($categoryIds))
$this->categoryLinkManagementInterface->assignProductToCategories(
$product->getSku(),
$categoryIds
);
answered 7 mins ago
Dominic XigenDominic Xigen
414
414
add a comment |
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%2f260866%2fremoving-categorty-in-product-page-is-giving-error%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