This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
namespace Mageplaza\Blog\Block\Sidebar;
use Mageplaza\Blog\Block\Frontend;
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
/**
* Class MostView
* @package Mageplaza\Blog\Block\Sidebar
*/
class MostView extends Frontend
{
/**
* @return Collection
*/
public function getMostViewPosts()
{
$collection = $this->helperData->getPostList();
$collection->getSelect()
->joinLeft(
['traffic' => $collection->getTable('mageplaza_blog_post_traffic')],
'main_table.post_id=traffic.post_id',
'numbers_view'
)
->order('numbers_view DESC')
->limit((int)$this->helperData->getBlogConfig('sidebar/recent_post/number_mostview_posts') ?: 4);
return $collection;
}
/**
* @return Collection
*/
public function getRecentPost()
{
$collection = $this->helperData->getPostList();
$collection->getSelect()
->limit((int)$this->helperData->
getBlogConfig('sidebar/recent_post/number_recent_posts') ?: 4);
return $collection;
}
}
+75
View File
@@ -0,0 +1,75 @@
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
namespace Mageplaza\Blog\Block\Sidebar;
use Magento\Framework\Exception\NoSuchEntityException;
use Mageplaza\Blog\Block\Frontend;
use Mageplaza\Blog\Helper\Data;
/**
* Class Search
* @package Mageplaza\Blog\Block\Sidebar
*/
class Search extends Frontend
{
/**
* @return string
* @throws NoSuchEntityException
*/
public function getSearchBlogData()
{
$result = [];
$posts = $this->helperData->getPostList();
$limitDesc = (int)$this->getSidebarConfig('search/description');
if (!empty($posts)) {
foreach ($posts as $item) {
$shortDescription = ($item->getShortDescription() && $limitDesc > 0) ?
$item->getShortDescription() : '';
if (strlen($shortDescription) > $limitDesc) {
$shortDescription = mb_substr($shortDescription, 0, $limitDesc, 'UTF-8') . '...';
}
$result[] = [
'value' => $item->getName(),
'url' => $item->getUrl(),
'image' => $this->resizeImage($item->getImage(), '100x'),
'desc' => $shortDescription
];
}
}
return Data::jsonEncode($result);
}
/**
* get sidebar config
*
* @param $code
* @param $storeId
*
* @return mixed
*/
public function getSidebarConfig($code, $storeId = null)
{
return $this->helperData->getBlogConfig('sidebar/' . $code, $storeId);
}
}