3131use Magento \Framework \Data \Collection \AbstractDb ;
3232use Magento \Framework \DataObject ;
3333use Magento \Framework \Escaper ;
34+ use Magento \Framework \Exception \FileSystemException ;
3435use Magento \Framework \Exception \LocalizedException ;
36+ use Magento \Framework \Exception \NoSuchEntityException ;
37+ use Magento \Framework \Exception \ValidatorException ;
3538use Magento \Framework \Filesystem ;
3639use Magento \Framework \Model \Context ;
3740use Magento \Framework \Model \ResourceModel \AbstractResource ;
4548use Magento \Sitemap \Model \Sitemap as CoreSitemap ;
4649use Magento \Store \Model \StoreManagerInterface ;
4750use 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 {
@@ -393,9 +401,7 @@ public function _getProductCollection($storeId)
393401 if ($ this ->_coreProductFactory ->create ()->load ($ item ->getId ())->getData ('mp_exclude_sitemap ' ) == 1 ) {
394402 continue ;
395403 }
396- if ($ this ->stockItem ->load ($ item ->getId (), 'product_id ' )->getIsInStock () == 0 ) {
397- continue ;
398- }
404+
399405 $ collection [] = $ item ;
400406 }
401407
@@ -405,7 +411,7 @@ public function _getProductCollection($storeId)
405411 /**
406412 * Convert Url
407413 *
408- * @param $url
414+ * @param string $url
409415 *
410416 * @return string
411417 */
@@ -421,8 +427,8 @@ public function convertUrl($url)
421427 /**
422428 * Remove the link of the CMS page using for homepage.
423429 *
424- * @param $storeId
425- * @param $page
430+ * @param int $storeId
431+ * @param Object $page
426432 *
427433 * @return bool
428434 */
0 commit comments