How to import(via csv) custom field(placeholder) in custom CMS Block?
i have created a custom CMS Block and inside it placeholder named "image".
In cms_block.csv there is no such placeholder in csv header, but if i add it and properly enter data it is not stored in db after running import.
Is is possible to import custom placeholder via csv?
and tutorial or documentation on that tomic?
Best Answer
-
Heyhey,
I have never done this by myself yet but let me try to help you find a solution by yourself.
First we need to understand which importer we use. Look in which import yml file the
cms_block.csvis linked so you get the data-type: so open for exampledata/import/local/full_EU.ymland you will see:- data_entity: cms-block
source: data/import/common/common/cms_block.csvNow lets do a full text search in
src/Pyz/Zed/DataImportfor the data_entity "cms-block". We will find the constantIMPORT_TYPE_CMS_BLOCKinsrc/Pyz/Zed/DataImport/DataImportConfig.php.Lets do another search in that same module for that constant and we will find an usage in
src/Pyz/Zed/DataImport/Business/DataImportBusinessFactory.phpand the matchingcreateCmsBlockImporter()method.Have a look at that method and focus on the following part:
$dataSetStepBroker->addStep($this->createAddLocalesStep())
->addStep($this->createLocalizedAttributesExtractorStep([
CmsBlockWriterStep::KEY_PLACEHOLDER_TITLE, CmsBlockWriterStep::KEY_PLACEHOLDER_CONTENT, CmsBlockWriterStep::KEY_PLACEHOLDER_LINK, CmsBlockWriterStep::KEY_PLACEHOLDER_IMAGE_URL, ]))
->addStep(new CmsBlockWriterStep());This gives us already an idea which Step we have to analyze.
createLocalizedAttributesExtractorStep()which instantiatesvendor/spryker/data-import/src/Spryker/Zed/DataImport/Business/Model/DataImportStep/LocalizedAttributesExtractorStep.php. Looking into that step we see there is not much additional logic. So we will have to go back to the methodcreateCmsBlockImporter()insrc/Pyz/Zed/DataImport/Business/DataImportBusinessFactory.phpand just add our new placeholder there as well.Not sure if sth is missing there but this should hopefully lead you to the rightsolution :)
All the best,
Florian
0
Answers
-
Heyhey,
I have never done this by myself yet but let me try to help you find a solution by yourself.
First we need to understand which importer we use. Look in which import yml file the
cms_block.csvis linked so you get the data-type: so open for exampledata/import/local/full_EU.ymland you will see:- data_entity: cms-block
source: data/import/common/common/cms_block.csvNow lets do a full text search in
src/Pyz/Zed/DataImportfor the data_entity "cms-block". We will find the constantIMPORT_TYPE_CMS_BLOCKinsrc/Pyz/Zed/DataImport/DataImportConfig.php.Lets do another search in that same module for that constant and we will find an usage in
src/Pyz/Zed/DataImport/Business/DataImportBusinessFactory.phpand the matchingcreateCmsBlockImporter()method.Have a look at that method and focus on the following part:
$dataSetStepBroker->addStep($this->createAddLocalesStep())
->addStep($this->createLocalizedAttributesExtractorStep([
CmsBlockWriterStep::KEY_PLACEHOLDER_TITLE, CmsBlockWriterStep::KEY_PLACEHOLDER_CONTENT, CmsBlockWriterStep::KEY_PLACEHOLDER_LINK, CmsBlockWriterStep::KEY_PLACEHOLDER_IMAGE_URL, ]))
->addStep(new CmsBlockWriterStep());This gives us already an idea which Step we have to analyze.
createLocalizedAttributesExtractorStep()which instantiatesvendor/spryker/data-import/src/Spryker/Zed/DataImport/Business/Model/DataImportStep/LocalizedAttributesExtractorStep.php. Looking into that step we see there is not much additional logic. So we will have to go back to the methodcreateCmsBlockImporter()insrc/Pyz/Zed/DataImport/Business/DataImportBusinessFactory.phpand just add our new placeholder there as well.Not sure if sth is missing there but this should hopefully lead you to the rightsolution :)
All the best,
Florian
0 -
Thank you.
Works perfectly1
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 92 Spryker News
- 1K Developer Corner
- 855 Spryker Development
- 93 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 36 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 35 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 34 Product & Business Questions
- 70 Spryker Safari Questions
- 51 Random