πŸ‘‹ Hi everyone! I am working on Category listing PLP page , I have add a description field in 's

U04UE6DF06N
U04UE6DF06N Posts: 77 πŸ§‘πŸ»β€πŸš€ - Cadet
edited June 2023 in Spryker Development

πŸ‘‹ Hi everyone!
I am working on Category listing PLP page , I have add a description field in 'spy_category' table and Show that in Zed Category add and edit form and store value for it .
Now i want that when ever we are going to any categoryfrom navigation so i want that attribute to display in Yves frontend On PLP page. i am not getting that attribute in indexAction of CatalogController we are getting the catagoryNode but there is not description attribute , and i dont know where the route defined please suggest me

Comments

  • UP8T3GKFH
    UP8T3GKFH Posts: 56 πŸ§‘πŸ»β€πŸš€ - Cadet

    Hi Aashutosh, you are on the right way. We have set the description in 'spy_category_attribute' and than you can read and write the drescription via 'CategoryLocalizedAttributesMapper' and extend the 'mapCategoryLocalizedAttributesTransfersToCategoryNodeStorageTransferForLocale' with the categoryDescription.
    As next step we have added the description in the 'executeIndexAction' to the 'searchResults' and the last step is to add the categoryDescription to {% define data = { ..., categoryDescription: _view.categoryDecription, ...} %} in the catalog.twig.
    I hope this helps you with the implementation.

  • U04UE6DF06N
    U04UE6DF06N Posts: 77 πŸ§‘πŸ»β€πŸš€ - Cadet

    Thanks for reply , I have gone through that execueIndex method in serach result there is no field related to description there is only metaDescription , and in nodeCategory there are only category id , Actually i have added a new field in 'spy_category' table not 'spy_category_attribut' so my requirement for getting the descripion field which i have created from 'spy_category' table

  • U04UE6DF06N
    U04UE6DF06N Posts: 77 πŸ§‘πŸ»β€πŸš€ - Cadet

    Please suggest me it is not working

  • UP8T3GKFH
    UP8T3GKFH Posts: 56 πŸ§‘πŸ»β€πŸš€ - Cadet

    Hi, okay, but why do you set the field to "spy_category" and not "spy_category_attribute". With your method you can't use language dependent descriptions .
    Of course there is no entry for the description in the 'executeIndexAction', you still have to add that there.

  • UP8T3GKFH
    UP8T3GKFH Posts: 56 πŸ§‘πŸ»β€πŸš€ - Cadet

    Unfortunately, there is no ootb solution for category descriptions. Everything has to be built. Database fields, additional entries in the transfer objects and, of course, the storage entries so that the data also arrive in Yves.

  • U04UE6DF06N
    U04UE6DF06N Posts: 77 πŸ§‘πŸ»β€πŸš€ - Cadet

    So should i have that entry into the 'spy_category_attributes'

  • U04UE6DF06N
    U04UE6DF06N Posts: 77 πŸ§‘πŸ»β€πŸš€ - Cadet

    if i create field into the 'spy_category_attribute' soi will be able to get data in StorageNodeTransfer ?

  • UP8T3GKFH
    UP8T3GKFH Posts: 56 πŸ§‘πŸ»β€πŸš€ - Cadet

    you have to add the field in CategoryTransfer, CategoryLocalizedAttributesTransfer and in CategoryNodeStorageTransfer.
    And as i wrote in my first answer you have to set the Description in CategoryLocalizedAttributesMapper.

    public function mapCategoryLocalizedAttributesTransfersToCategoryNodeStorageTransferForLocale(
        ArrayObject $categoryLocalizedAttributesTransfers,
        CategoryNodeStorageTransfer $categoryNodeStorageTransfer,
        string $localeName
    ): CategoryNodeStorageTransfer {
        $categoryLocalizedAttributesTransfer = $this->findCategoryLocalizedAttributesTransferForLocale(
            $categoryLocalizedAttributesTransfers,
            $localeName,
        );
    
        if (!$categoryLocalizedAttributesTransfer) {
            return $categoryNodeStorageTransfer;
        }
    
        if ($categoryLocalizedAttributesTransfer->getImage()) {
            $categoryNodeStorageTransfer->setImage($categoryLocalizedAttributesTransfer->getImageOrFail()->getNameOrFail());
        }
    
        return $categoryNodeStorageTransfer
            ->setUrl($categoryLocalizedAttributesTransfer->getUrl())
            ->setName($categoryLocalizedAttributesTransfer->getName())
            ->setMetaTitle($categoryLocalizedAttributesTransfer->getMetaTitle())
            ->setMetaDescription($categoryLocalizedAttributesTransfer->getMetaDescription())
            ->setMetaKeywords($categoryLocalizedAttributesTransfer->getMetaKeywords())
            ->setCategoryDescription($categoryLocalizedAttributesTransfer->getCategoryDescription());
    }
    

    Then the Description should be written in the CategoryNodeStorage and you could read it from the CategoryNodes in the Yves.

  • U04UE6DF06N
    U04UE6DF06N Posts: 77 πŸ§‘πŸ»β€πŸš€ - Cadet

    okk

  • U04UE6DF06N
    U04UE6DF06N Posts: 77 πŸ§‘πŸ»β€πŸš€ - Cadet

    thanks

  • U04UE6DF06N
    U04UE6DF06N Posts: 77 πŸ§‘πŸ»β€πŸš€ - Cadet

    where is this function present in which file can you please explain more , i am new to spryker

  • UP8T3GKFH
    UP8T3GKFH Posts: 56 πŸ§‘πŸ»β€πŸš€ - Cadet

    This method is located in the Spryker\Zed\CategoryStorage\Business\Mapper\CategoryLocalizedAttributesMapper so you have to extend that method in your namespace or in the Pyz namespace.
    Regardless, I highly recommend doing the free tutorials in the Spryker Academy. https://academy.spryker.com Without understanding the basic structure of Spryker, it is very difficult to implement good projects.

  • U04UE6DF06N
    U04UE6DF06N Posts: 77 πŸ§‘πŸ»β€πŸš€ - Cadet

    Thank you so much for your help