0

(Sorry for my English. It will be great if you correct my mistakes). I have a list of products and create product / edit product pages. Each product has a set of attributes. Each set of attributes has attributes. How to do next: When i choose a set of attributes for product at creating or at editing, in the form (create product / edit product) will be added new TextInputs with labels of attributes.

Here is my products:

products: [
{
  id: 1,
  title: 'title1',
  description: 'description1',
  shortDescription: 'shortDescription1',
  seo: {
    title: 'seotitle1',
    description: 'description1',
    keywords: ['keywords1'],
  },
  price: 428,
  parentCategories: [1],
  images: [
    {
      id: 123,
      url: 'urlImage1',
      title: 'urlTitle1',
    },
  ],
  isItActive: true,
  creationDate: '2008-04-01T14:57:42.105Z',
  modificationDate: '2009-04-01T14:57:42.105Z',
  setOfAttributes: 1,
}, {
  id: 2,
  title: 'title2',
  description: 'description2',
  shortDescription: 'shortDescription2',
  seo: {
    title: 'seotitle2',
    description: 'description2',
    keywords: ['keywords2'],
  },
  price: 418,
  parentCategories: [2],
  images: [
    {
      id: 122,
      url: 'urlImage2',
      title: 'urlTitle2',
    },
  ],
  isItActive: false,
  creationDate: '2010-04-01T14:57:42.105Z',
  modificationDate: '2011-04-01T14:57:42.105Z',
  setOfAttributes: 3,
}, {
  id: 3,
  title: 'title3',
  description: 'description3',
  shortDescription: 'shortDescription3',
  seo: {
    title: 'seotitle3',
    description: 'description3',
    keywords: ['keywords3'],
  },
  price: 423,
  parentCategories: [3],
  images: [
    {
      id: 323,
      url: 'urlImage3',
      title: 'urlTitle3',
    },
  ],
  isItActive: true,
  creationDate: '2012-04-01T14:57:42.105Z',
  modificationDate: '2013-04-01T14:57:42.105Z',
  setOfAttributes: 2,
},

],

Here is my attrubutes:

attributes: [
{
  id: 1,
  name: 'asdgsd',
  title: 'qwed',
  type: 'список',
  showInFilter: null,
},
{
  id: 2,
  name: 'zxcv',
  title: 'fkf',
  type: 'текстовое поле',
  showInFilter: null,
},
{
  id: 3,
  name: 'asdkd',
  title: 'rczh',
  type: null,
  showInFilter: null,
},

],

Here is a set of attributes:

setOfAttributes: [
{
  id: 1,
  title: 'Набор 1',
  attributes: [1, 3],
},
{
  id: 2,
  title: 'Набор 2',
  attributes: [3, 1, 2],
},
{
  id: 3,
  title: 'Набор 3',
  attributes: [2, 3],
},

],

I was able to do just that(productsEdit.jsx):

<ReferenceField source="setOfAttributes" reference="setOfAttributes" linkType={false}>
     <ReferenceArrayField source="attributes" reference="attributes">
         <SingleFieldList>
            <ChipField source="title" />
         </SingleFieldList>
     </ReferenceArrayField>
</ReferenceField>
Reymor
  • 1

0 Answers0