Skip to content

Commit

Permalink
Merge pull request #359 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
phutx authored May 22, 2023
2 parents 301b157 + 37d9294 commit d1a6b06
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public function getSelectedPostsCollection()
$collection = $this->postCollectionFactory->create();
$collection->join(
['cat' => $this->getResource()->getTable('mageplaza_blog_post_category')],
'main_table.post_id=cat.post_id AND cat.category_id=' . $this->getId(),
'main_table.post_id=cat.post_id AND cat.category_id=' . (int) $this->getId(),
['position']
);
$collection->setOrder('post_id','DESC');
Expand Down
19 changes: 11 additions & 8 deletions Setup/Patch/Data/InsertData.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,18 @@ public function __construct(
*/
public function apply()
{
$defaultData = [
'name' => 'Admin',
'type' => 0,
'status' => 1,
'created_at' => $this->date->date()
];

if (!$this->authorFactory->create()->getCollection()->getSize()) {
$this->authorFactory->create()->addData(
[
'name' => 'Admin',
'type' => 0,
'status' => 1,
'created_at' => $this->date->date()
]
)->save();
$this->moduleDataSetup->getConnection()->insertOnDuplicate(
$this->moduleDataSetup->getTable('mageplaza_blog_author'),
$defaultData
);
}
}

Expand Down
26 changes: 16 additions & 10 deletions Setup/Patch/Data/InsertRootCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class InsertRootCategory implements
private $categoryFactory;

/**
* InsertRootCategory constructor.
* @param ModuleDataSetupInterface $moduleDataSetup
* @param CategoryFactory $categoryFactory
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
Expand All @@ -64,17 +66,21 @@ public function __construct(
*/
public function apply()
{
$defaultData = [
'store_ids' => 0,
'parent_id' => null,
'path' => '1',
'position' => 0,
'children_count' => 0,
'level' => 0,
'name' => 'ROOT',
'url_key' => 'root'
];
if (!$this->categoryFactory->create()->getCollection()->getSize()) {
$this->categoryFactory->create()->addData(
[
'path' => '1',
'position' => 0,
'children_count' => 0,
'level' => 0,
'name' => 'ROOT',
'url_key' => 'root'
]
)->save();
$this->moduleDataSetup->getConnection()->insertOnDuplicate(
$this->moduleDataSetup->getTable('mageplaza_blog_category'),
$defaultData
);
}
}

Expand Down

0 comments on commit d1a6b06

Please sign in to comment.