Open diwipl opened 7 years ago
Thanks for reporting this - internal ticket MAGETWO-70400 has been created to track this issue. You really shouldn't be setting the "children" to 1, as that ID is usually reserved for the root catalog, but other values didn't work for me either, even when specifying "position" and "level" fields.
The value was there just so the field "children" is not empty because that is triggering the error.
@diwipl, thank you for your report. We've created internal ticket(s) MAGETWO-70400 to track progress on the issue.
Hi @devamitbera. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:
[ ] 1. Add/Edit Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 2. Verify that the issue is reproducible on 2.3-develop
branchDetails
- Add the comment @magento-engcom-team give me 2.3-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop
branch, please, add the label Reproduced on 2.3.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 3. Verify that the issue is reproducible on 2.2-develop
branch. Details
- Add the comment @magento-engcom-team give me 2.2-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.2-develop
branch, please add the label Reproduced on 2.2.x
[ ] 4. If the issue is not relevant or is not reproducible any more, feel free to close it.
I am working on #MM19IN
I have able to produce the same issue.
Trying with Post getting the error:
{ "message": "Property \"Children\" does not have accessor method \"setChildren\" in class \"Magento\Catalog\Api\Data\CategoryInterface\".", "trace": "#0 /var/www/html/sample230/vendor/magento/framework/Reflection/NameFinder.php(74): Magento\Framework\Reflection\NameFinder->findAccessorMethodName(Object(Zend\Code\Reflection\ClassReflection), 'Children', 'setChildren', 'setIsChildren')\n#1 /var/www/html/sample230/vendor/magento/framework/Webapi/ServiceInputProcessor.php(235): Magento\Framework\Reflection\NameFinder->getSetterMethodName(Object(Zend\Code\Reflection\ClassReflection), 'Children')\n#2 /var/www/html/sample230/vendor/magento/framework/Webapi/ServiceInputProcessor.php(411): Magento\Framework\Webapi\ServiceInputProcessor->_createFromArray('Magento\\Catalog...', Array)\n#3 /var/www/html/sample230/vendor/magento/framework/Webapi/ServiceInputProcessor.php(152): Magento\Framework\Webapi\ServiceInputProcessor->convertValue(Array, 'Magento\\Catalog...')\n#4 /var/www/html/sample230/vendor/magento/module-webapi/Controller/Rest/InputParamsResolver.php(101): Magento\Framework\Webapi\ServiceInputProcessor->process('Magento\\Catalog...', 'save', Array)\n#5 /var/www/html/sample230/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(85): Magento\Webapi\Controller\Rest\InputParamsResolver->resolve()\n#6 /var/www/html/sample230/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy))\n#7 /var/www/html/sample230/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))\n#8 /var/www/html/sample230/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->callParent('dispatch', Array)\n#9 /var/www/html/sample230/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#10 /var/www/html/sample230/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\Webapi\Controller\Rest\Interceptor->callPlugins('dispatch', Array, Array)\n#11 /var/www/html/sample230/vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#12 /var/www/html/sample230/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()\n#13 /var/www/html/sample230/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#14 {main}" }
I don't think to define of setChildren
at API data interface is not fully solution at this case.
If we define the setChildren function, then what action will run from this method/function
There are some scenarios, where what I need advice about what action will need to implement that case.
In my point, we have to remove that children
from API.
At current 2.3-develop does not have any setter function at Magento\Catalog\Api\Data\CategoryInterface
So if we have added this method to this class and its rewrite data class Magento\Catalog\Model\Catgory
Then it cannot be work as children
is not an attribute of caegory. There are some extact function need at Magento\Catalog\Model\Catgory
for save children categories.
During the POST method, if we add provide like params "children": "12,13",
at POST/PUT ,then its means there are will be existing two categories 12,13
will be move under category 11.
{
"id": 11,
"parent_id": 2,
"name": "Men",
"is_active": true,
"position": 3,
"level": 2,
"children": "12,13",
"created_at": "2018-12-07 04:33:59",
"updated_at": "2018-12-07 04:34:01",
"path": "1/2/11",
"available_sort_by": [],
"include_in_menu": true,
"custom_attributes": [
{
"attribute_code": "display_mode",
"value": "PAGE"
},
{
"attribute_code": "is_anchor",
"value": "0"
},
{
"attribute_code": "path",
"value": "1/2/11"
},
{
"attribute_code": "custom_layout_update",
"value": "<referenceContainer name=\"catalog.leftnav\" remove=\"true\"/>"
},
{
"attribute_code": "children_count",
"value": "8"
},
{
"attribute_code": "url_key",
"value": "men"
},
{
"attribute_code": "url_path",
"value": "men"
}
]
}
As per as, Magento behaviour you can only move when a category is existing at the system. So when we have using PUT method of update the database and then one of a category which already belongs to that request, not sending with the new request then what will happen or that subcategory?
So, @magento-engcom-team Please suggest what you want to implement for case of PUT /POST. of this API point?
@magento-engcom-team , Do you guys has any suggestion on this issue?
@magento-engcom-team ,any body has any feedback on my suggestion over comment https://github.com/magento/magento2/issues/10088#issuecomment-460028255
i have two solutions to this issue
Solution 1:
Remove children from data provider means remove public function getChildren(); method from https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Catalog/Api/Data/CategoryInterface.php#L137
If we remove the getter field then there no means add setter method on the data provider interface and also on the model class.
Solution2:
If We will added setter method setChildren to both data interface and model class
then there are fewer scenarios will happen where setchildren()
method behaviour is unknown or confusing.
Let. Explain in scenario (edited)
Case1: POST method request, Assume that Category name Clothing and children: field params like children: T-shirt, Shirt
It means T-shirt, Shirt category already exists at the system and we have to move this category under my category.
Case2: PUT REQUEST Assume that Category name Clothing and its existing children T-shirt, Shirt. Now i set "children": "Shirt,Jeans", for PUT request
In that case what will happen for T-shirt category? Should we delete that category OR Move under Root category?
Case3:PUT REQUEST Assume that Category name Clothing and its existing children T-shirt, Shirt. Now i set "children": "Shirt,Jeans", for put request and where Jeans is a subcategory of X and its means that case move functionality happens of Jean category? I hope, you will able to understand my query
if I will implement second option Then there are 3 scenario where the behavior of the API is confusing So, can you please discussion with magneto core team about the above 3 scenarios And can confirm the behavior
Hi @devamitbera. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
[ ] 1. Add/Edit Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 2. Verify that the issue is reproducible on 2.3-develop
branchDetails
- Add the comment @magento give me 2.3-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop
branch, please, add the label Reproduced on 2.3.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 3. Verify that the issue is reproducible on 2.2-develop
branch. Details
- Add the comment @magento give me 2.2-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.2-develop
branch, please add the label Reproduced on 2.2.x
[ ] 4. If the issue is not relevant or is not reproducible any more, feel free to close it.
@sidolov
As per my last PR #22710 and Magento backward Compitable issue, I cannot modify exits API data Interface CategoryInterface.php
.
So, my question is that should I create a new data interface for CategoryInterface?
The second question, if yes then is only need to add setter functions on that new interface?
Current CategoryInterface does not only setter method setChildren is missing.
Please let me know your view on this case.
Thanks Amit Bera
@sidolov
I introduce new data interface and reposityinterce.
Please look the commit https://github.com/devamitbera/magento2/commit/07b19858a3edf6ce371f3b32f9fbdb6ad0142422
Is the right way i going?
@sidolov and @magento-engcom-team
Can you please take a look on my last commit https://github.com/devamitbera/magento2/commit/07b19858a3edf6ce371f3b32f9fbdb6ad0142422
Hi @devamitbera , please, take a look at PR that introduced ability to handle parameters in the constructor for WebAPI interfaces: https://github.com/magento/magento2/pull/14801 Probably, we may resolve the current issue with the mentioned approach instead of new interfaces declaration.
@sidolov Thanks for your help. I am checking your suggestion.
@sidolov
Doing changes respect to #14801 , i need change data format of a parameter
{
"category":{
"id": 11,
"parent_id": 2,
"name": "Men_test",
"is_active": true,
"position": 3,
"level": 2,
"children":{"ids":"12,15"},
"created_at": "2019-08-08 11:27:16",
"updated_at": "2019-08-08 11:27:18",
"path": "1/2/11",
"available_sort_by":[] ,
"include_in_menu": true,
"custom_attributes": [
{
"attribute_code": "display_mode",
"value": "PAGE"
},
{
"attribute_code": "is_anchor",
"value": "0"
},
{
"attribute_code": "path",
"value": "1/2/11"
},
{
"attribute_code": "custom_layout_update",
"value": "<referenceContainer name=\"catalog.leftnav\" remove=\"true\"/>"
},
{
"attribute_code": "children_count",
"value": "8"
},
{
"attribute_code": "url_key",
"value": "men"
},
{
"attribute_code": "url_path",
"value": "men"
}
]
}
}
I need to format of a parameter
Can use :
Option 1: "children":{"ids":"12,15"},
from "children":"12,15",
Option 2: Or i need to use
"children": [
{
"id": "12"
},
{
"id": "15"
}
]
Please confirm the format, i will implement this format accordingly.
@sidolov
Just start work with option seems it not possible to implement using adding parameters in the constructor for WebAPI interfaces
It wills broken at Magento\Framework\Webapi\ServiceInputProcessor::_createFromArray
$methodName = $this->getNameFinder()->getGetterMethodName($class, $camelCaseProperty);
During debugging, i have found that
$className: value is Magento\Catalog\Model\CategorySetChildren
; (Is my parameter of the constructor for WebAPI interfaces)
$data
Array
(
[0] => Array
(
[id] => 12
)
[1] => Array
(
[id] => 13
)
)
And as Index is 0 that getting error at https://github.com/magento/magento2/blob/2.3-develop/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php#L235
"message": "Property \"0\" does not have accessor method \"get0\" in class \"Magento\\Catalog\\Model\\CategorySetChildren\".",
"trace": "#0 /var/www/html/magento23dev/lib/internal/Magento/Framework/Reflection/NameFinder.php(59): Magento\\Framework\\Reflection\\NameFinder->findAccessorMethodName(Object(Zend\\Code\\Reflection\\ClassReflection), '0', 'get0', 'is0')\n#1 /var/www/html/magento23dev/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php(286): Magento\\Framework\\Reflection\\NameFinder->getGetterMethodName(Object(Zend\\Code\\Reflection\\ClassReflection), '0')\n#2 /var/www/html/magento23dev/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php(541): Magento\\Framework\\Webapi\\ServiceInputProcessor->_createFromArray('Magento\\\\Catalog...', Array)\n#3 /var/www/html/magento23dev/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php(223): Magento\\Framework\\Webapi\\ServiceInputProcessor->convertValue(Array, 'Magento\\\\Catalog...')\n#4 /var/www/html/magento23dev/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php(269): Magento\\Framework\\Webapi\\ServiceInputProcessor->getConstructorData('Magento\\\\Catalog...', Array)\n#5 /var/www/html/magento23dev/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php(541): Magento\\Framework\\Webapi\\ServiceInputProcessor->_createFromArray('Magento\\\\Catalog...', Array)\n#6 /var/www/html/magento23dev/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php(164): Magento\\Framework\\Webapi\\ServiceInputProcessor->convertValue(Array, 'Magento\\\\Catalog...')\n#7 /var/www/html/magento23dev/app/code/Magento/Webapi/Controller/Rest/InputParamsResolver.php(101): Magento\\Framework\\Webapi\\ServiceInputProcessor->process('Magento\\\\Catalog...', 'save', Array)\n#8
As per as, #14801 , parameter format should be Option 1 See Test https://github.com/magento/magento2/pull/14801/files#diff-0b29f209833bd983932b1df49d9d8494R208
Please let me know your view on this.Do you want suggest me continue with Option 2 or Option 1
@sidolov
Here my Modified: Magento\Catalog\Model\Ctegory
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Model;
use Magento\Authorization\Model\UserContextInterface;
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator;
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Convert\ConvertArray;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Profiler;
use Magento\UrlRewrite\Model\UrlFinderInterface;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
/**
* Catalog category
*
* @api
* @method Category setAffectedProductIds(array $productIds)
* @method array getAffectedProductIds()
* @method Category setMovedCategoryId(array $productIds)
* @method int getMovedCategoryId()
* @method Category setAffectedCategoryIds(array $categoryIds)
* @method array getAffectedCategoryIds()
* @method Category setUrlKey(string $urlKey)
* @method Category setUrlPath(string $urlPath)
* @method Category getSkipDeleteChildren()
* @method Category setSkipDeleteChildren(boolean $value)
* @method Category setChangedProductIds(array $categoryIds) Set products ids that inserted or deleted for category
* @method array getChangedProductIds() Get products ids that inserted or deleted for category
*
* @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
class Category extends \Magento\Catalog\Model\AbstractModel implements
\Magento\Framework\DataObject\IdentityInterface,
\Magento\Catalog\Api\Data\CategoryInterface,
\Magento\Catalog\Api\Data\CategoryTreeInterface
{
/**
* @var \Magento\Catalog\Model\CategorySetChildren
*/
private $children;
/**
* Entity code.
* Can be used as part of method name for entity processing
*/
const ENTITY = 'catalog_category';
....
private $userContext;
/**
* @var AuthorizationInterface
*/
private $authorization;
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
* @param AttributeValueFactory $customAttributeFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService
* @param \Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTreeResource
* @param \Magento\Catalog\Model\ResourceModel\Category\TreeFactory $categoryTreeFactory
* @param \Magento\Store\Model\ResourceModel\Store\CollectionFactory $storeCollectionFactory
* @param \Magento\Framework\UrlInterface $url
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
* @param Config $catalogConfig
* @param \Magento\Framework\Filter\FilterManager $filter
* @param Indexer\Category\Flat\State $flatState
* @param \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator
* @param UrlFinderInterface $urlFinder
* @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry
* @param CategoryRepositoryInterface $categoryRepository
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
AttributeValueFactory $customAttributeFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService,
\Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTreeResource,
\Magento\Catalog\Model\ResourceModel\Category\TreeFactory $categoryTreeFactory,
\Magento\Store\Model\ResourceModel\Store\CollectionFactory $storeCollectionFactory,
\Magento\Framework\UrlInterface $url,
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
\Magento\Catalog\Model\Config $catalogConfig,
\Magento\Framework\Filter\FilterManager $filter,
Indexer\Category\Flat\State $flatState,
\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator,
UrlFinderInterface $urlFinder,
\Magento\Framework\Indexer\IndexerRegistry $indexerRegistry,
CategoryRepositoryInterface $categoryRepository,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
\Magento\Catalog\Model\CategorySetChildren $children = null,
array $data = []
) {
$this->metadataService = $metadataService;
$this->_treeModel = $categoryTreeResource;
$this->_categoryTreeFactory = $categoryTreeFactory;
$this->_storeCollectionFactory = $storeCollectionFactory;
$this->_url = $url;
$this->_productCollectionFactory = $productCollectionFactory;
$this->_catalogConfig = $catalogConfig;
$this->filter = $filter;
$this->flatState = $flatState;
$this->categoryUrlPathGenerator = $categoryUrlPathGenerator;
$this->urlFinder = $urlFinder;
$this->indexerRegistry = $indexerRegistry;
$this->categoryRepository = $categoryRepository;
$this->children = $children;
parent::__construct(
$context,
$registry,
$extensionFactory,
$customAttributeFactory,
$storeManager,
$resource,
$resourceCollection,
$data
);
}
Hi @devamitbera. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
[ ] 1. Add/Edit Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 2. Verify that the issue is reproducible on 2.3-develop
branchDetails
- Add the comment @magento give me 2.3-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop
branch, please, add the label Reproduced on 2.3.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.
Hi @devamitbera. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
[ ] 1. Add/Edit Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 2. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.
+1
+1 - I'm having to unset this key prior to an Update everytime!
@magento I am working on this.
Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x
, ^Area:.*
Once all required labels are present, please add Issue: Confirmed
label again.
Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x
, ^Area:.*
Once all required labels are present, please add Issue: Confirmed
label again.
:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-994 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-994
:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-994
@magento give me 2.4-develop instance
Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.
Hi @engcom-Bravo, here is your Magento Instance: https://e252ffde96c0c082564fe7548c4a9ae2.instances-prod.magento-community.engineering Admin access: https://e252ffde96c0c082564fe7548c4a9ae2.instances-prod.magento-community.engineering/admin_a4d1 Login: 3f82b383 Password: 63c2f3f79034
"children" field should not be included in documentation ( http://devdocs.magento.com/swagger/index_21.html ) of possible body of POST /V1/categories in catalogCategoryRepositoryV1 or it should be ignored in webservice itself.
The same applies to documentation of body of PUT /V1/categories/{id} webservice.
Preconditions
Steps to reproduce
Expected result
Actual result
Exception log: