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

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

Welcome!

It looks like you're new here. Sign in or register to get started.

Comments

  • 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.

  • 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

  • Posts: 77 🧑🏻‍🚀 - Cadet

    Please suggest me it is not working

  • 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.

  • 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.

  • Posts: 77 🧑🏻‍🚀 - Cadet

    So should i have that entry into the 'spy_category_attributes'

  • Posts: 77 🧑🏻‍🚀 - Cadet

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

  • 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.

  • Posts: 77 🧑🏻‍🚀 - Cadet

    okk

  • Posts: 77 🧑🏻‍🚀 - Cadet

    thanks

  • Posts: 77 🧑🏻‍🚀 - Cadet

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

  • 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.

  • Posts: 77 🧑🏻‍🚀 - Cadet

    Thank you so much for your help

Welcome!

It looks like you're new here. Sign in or register to get started.