Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

Commit 345b748

Browse files
committed
clean code & update composer
1 parent 3ef26a8 commit 345b748

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

Model/Sitemap.php

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
use Magento\Framework\Data\Collection\AbstractDb;
3232
use Magento\Framework\DataObject;
3333
use Magento\Framework\Escaper;
34+
use Magento\Framework\Exception\FileSystemException;
3435
use Magento\Framework\Exception\LocalizedException;
36+
use Magento\Framework\Exception\NoSuchEntityException;
37+
use Magento\Framework\Exception\ValidatorException;
3538
use Magento\Framework\Filesystem;
3639
use Magento\Framework\Model\Context;
3740
use Magento\Framework\Model\ResourceModel\AbstractResource;
@@ -45,6 +48,7 @@
4548
use Magento\Sitemap\Model\Sitemap as CoreSitemap;
4649
use Magento\Store\Model\StoreManagerInterface;
4750
use Mageplaza\Sitemap\Helper\Data as HelperConfig;
51+
use Zend_Db_Statement_Exception;
4852

4953
/**
5054
* Class Sitemap
@@ -202,24 +206,25 @@ public function _initSitemapItems()
202206
}
203207

204208
/**
205-
* @return $this
206-
* @throws Exception
209+
* @return $this|CoreSitemap
207210
* @throws LocalizedException
211+
* @throws FileSystemException
212+
* @throws ValidatorException
208213
*/
209214
public function generateXml()
210215
{
211216
$this->_initSitemapItems();
212217
/** @var $sitemapItem DataObject */
213218
foreach ($this->_sitemapItems as $item) {
214-
$changefreq = $item->getChangefreq();
219+
$changeFreq = $item->getChangefreq();
215220
$priority = $item->getPriority();
216221
$urlType = $item->getUrlType();
217222
foreach ($item->getCollection() as $itemChild) {
218223
$xml = $this->getSitemapRow(
219224
$itemChild->getUrl(),
220225
$urlType,
221226
$itemChild->getUpdatedAt(),
222-
$changefreq,
227+
$changeFreq,
223228
$priority,
224229
$itemChild->getImages()
225230
);
@@ -258,10 +263,10 @@ public function generateXml()
258263
/**
259264
* Get site map row
260265
*
261-
* @param $url
262-
* @param $urlType
263-
* @param null $lastmod
264-
* @param null $changefreq
266+
* @param string $url
267+
* @param int $urlType
268+
* @param null $lastMod
269+
* @param null $changeFreq
265270
* @param null $priority
266271
* @param null $images
267272
*
@@ -270,8 +275,8 @@ public function generateXml()
270275
protected function getSitemapRow(
271276
$url,
272277
$urlType,
273-
$lastmod = null,
274-
$changefreq = null,
278+
$lastMod = null,
279+
$changeFreq = null,
275280
$priority = null,
276281
$images = null
277282
) {
@@ -281,11 +286,11 @@ protected function getSitemapRow(
281286
$url = $this->convertUrl($url);
282287
}
283288
$row = '<loc>' . htmlspecialchars($url) . '</loc>';
284-
if ($lastmod) {
285-
$row .= '<lastmod>' . $this->_getFormattedLastmodDate($lastmod) . '</lastmod>';
289+
if ($lastMod) {
290+
$row .= '<lastmod>' . $this->_getFormattedLastmodDate($lastMod) . '</lastmod>';
286291
}
287-
if ($changefreq) {
288-
$row .= '<changefreq>' . $changefreq . '</changefreq>';
292+
if ($changeFreq) {
293+
$row .= '<changefreq>' . $changeFreq . '</changefreq>';
289294
}
290295
if ($priority) {
291296
$row .= sprintf('<priority>%.1f</priority>', $priority);
@@ -315,7 +320,7 @@ protected function getSitemapRow(
315320
/**
316321
* Get link collection added by config Additional Links
317322
*
318-
* @param $storeId
323+
* @param int $storeId
319324
*
320325
* @return array
321326
*/
@@ -339,7 +344,7 @@ public function getLinkCollectionAdded($storeId)
339344
/**
340345
* Get category collection
341346
*
342-
* @param $storeId
347+
* @param int $storeId
343348
*
344349
* @return array
345350
*/
@@ -360,7 +365,7 @@ public function _getCategoryCollection($storeId)
360365
/**
361366
* Get page collection
362367
*
363-
* @param $storeId
368+
* @param int $storeId
364369
*
365370
* @return array
366371
*/
@@ -382,9 +387,12 @@ public function _getPageCollection($storeId)
382387
/**
383388
* Get product Collection
384389
*
385-
* @param $storeId
390+
* @param int $storeId
386391
*
387392
* @return array
393+
* @throws LocalizedException
394+
* @throws NoSuchEntityException
395+
* @throws Zend_Db_Statement_Exception
388396
*/
389397
public function _getProductCollection($storeId)
390398
{
@@ -403,7 +411,7 @@ public function _getProductCollection($storeId)
403411
/**
404412
* Convert Url
405413
*
406-
* @param $url
414+
* @param string $url
407415
*
408416
* @return string
409417
*/
@@ -419,8 +427,8 @@ public function convertUrl($url)
419427
/**
420428
* Remove the link of the CMS page using for homepage.
421429
*
422-
* @param $storeId
423-
* @param $page
430+
* @param int $storeId
431+
* @param Object $page
424432
*
425433
* @return bool
426434
*/

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"mageplaza/magento-2-seo-extension": "^4.0.0"
77
},
88
"type": "magento2-module",
9-
"version": "4.0.0",
9+
"version": "4.0.1",
1010
"license": "proprietary",
1111
"authors": [
1212
{

0 commit comments

Comments
 (0)