enanobots / m2-datapatchcreator Goto Github PK
View Code? Open in Web Editor NEWLicense: Open Software License 3.0
License: Open Software License 3.0
If you have a CMS page or block with differing content in different websites but sharing the same identifier code, and try to export both at once, they'll get merged improperly and only content for one will get written to the data patch.
footer_links_col_5
)footer_links_col_5
blocks on the admin grid, and export with the data patch creatorI haven't investigated to determine if it creates both patches but one overwrites the other due to same filename (seems likely), or if they get grouped/merged by identifier prior to patch creation.
Secondary but related, since the existing record gets loaded by identifier without any scope filter, that will also cause incorrect behavior if multiple records exist with the same identifier, as in this case.
$cmsBlock = $this->blockFactory->create();
$this->blockResource->load($cmsBlock, 'footer_links_col_5', 'identifier');
It's not clear how the feature looks like. Would be great to add some screenshots or even gifs to show how it works
Could we introduce another template to create data patches that work with Mark's SimpleData module?
That would be great!
Files look fine when downloaded, but when saved directly to a folder, weird output happens:
<?php /**
* Created with Nanobots_DataPatchCreatorSimpleData
* @author Jakub Winkler <[email protected]>
*
* @category MarkShust
* @package MarkShust_MyData
*/
declare(strict_types = 1);
namespace MarkShust\MyData\Setup\Patch\Data;
use MarkShust\SimpleData\Setup\Patch\SimpleDataPatch;
class CmsPageHome extends SimpleDataPatch
{
public function apply(): void
{
$this->page->save([
'title' => 'Home page',
'page_layout' => '1column',
'meta_keywords' => '',
'meta_description' => '',
'identifier' => 'home',
'content_heading' => 'Home Page',
'content' => '<div data-content-type="html" data-appearance="default" data-element="main" data-decoded="true"><p>CMS homepage content goes here.</p>
</div>',
'creation_time' => '2021-10-29 15:45:29',
'update_time' => '2021-10-29 16:58:06',
'is_active' => '1',
'sort_order' => '0',
'layout_update_xml' => '<!--
<referenceContainer name="right">
<referenceBlock name="catalog.compare.sidebar" remove="true" />
</referenceContainer>-->',
'custom_theme' => '',
'custom_root_template' => '',
'custom_layout_update_xml' => null,
'layout_update_selected' => null,
'custom_theme_from' => null,
'custom_theme_to' => null,
'meta_title' => '',
'store_id' => [
0 => '0',
],
]);
}
}
Specifically, the >
arrows become >
.
If i use page builder in the block or page i facing some issues after exporting the patch data. Some character are not decoded properly. I have attached the error file with this ticket. Please check and give your feedback.
OS: Ubuntu 18.04
Magento 2.4.3-p1 (vanilla instance)
<?php /**
* Created with Nanobots_DataPatchCreator
* @author Jakub Winkler <[email protected]>
* @author Sebastian Strojwas <sebastian>
* @author Wojtek Wnuk <wojtek>
*
* @category
* @package HomePageBanner
*/
namespace HomePageBanner\Setup\Patch\Data;
use Exception;
use Magento\Cms\Model\BlockFactory;
use Magento\Cms\Model\ResourceModel\Block as BlockResource;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class CmsBlockHomeBannerCategoryList implements DataPatchInterface
{
/** @var BlockFactory */
private $blockFactory;
/** @var BlockResource */
private $blockResource;
/**
* @param BlockFactory $blockFactory
* @param BlockResource $blockResource
*/
public function __construct(
BlockFactory $blockFactory,
BlockResource $blockResource
) {
$this->blockFactory = $blockFactory;
$this->blockResource = $blockResource;
}
/**
* @inheritDoc
*/
public static function getDependencies(): array
{
return [];
}
/**
* @inheritDoc
*/
public function getAliases(): array
{
return [];
}
/**
* @inheritDoc
* @throws Exception
*/
public function apply(): self
{
try {
$cmsBlock = $this->blockFactory->create();
$this->blockResource->load($cmsBlock, 'home-banner-category-list', 'identifier');
$cmsBlock->addData([
'title' => 'Home Banner Category List',
'identifier' => 'home-banner-category-list',
'content' => '<style>#html-body [data-pb-style=Y96V1N8]{justify-content:flex-start;display:flex;flex-direction:column;background-position:left top;background-size:cover;background-repeat:no-repeat;background-attachment:scroll}</style><div data-content-type="row" data-appearance="contained" data-element="main"><div data-enable-parallax="0" data-parallax-speed="0.5" data-background-images="{}" data-background-type="image" data-video-loop="true" data-video-play-only-visible="true" data-video-lazy-load="true" data-video-fallback-src="" data-element="inner" data-pb-style="Y96V1N8"><div data-content-type="html" data-appearance="default" data-element="main" data-decoded="true">{{widget type="SomethingDigital\\CategoryWidget\\Block\\Category\\CategoriesList" categories_count="10" template="SomethingDigital_CategoryWidget::category/widget/content/list.phtml" parent_category_id="2"}}</div></div></div>',
'creation_time' => '2021-10-22 17:50:54',
'update_time' => '2021-10-22 19:13:18',
'is_active' => '1',
'row_id' => '5',
'created_in' => '1',
'updated_in' => '2147483647',
'store_id' => [
0 => '0',
],
'stores' => [
0 => '0',
],
]);
$this->blockResource->save($cmsBlock);
return $this;
} catch (Exception $e) {
throw new Exception(__('Cannot save CMS Block: %1', $e->getMessage()));
}
}
}
</wojtek></sebastian>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.