Skip to content

Commit 763cf8f

Browse files
committed
Next page url fix
1 parent eb05bab commit 763cf8f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lib/ShopifyResource.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,9 @@ public function getLink($responseHeaders, $type='next'){
562562
}
563563

564564
if(!empty($responseHeaders['link'])) {
565-
if (stristr($responseHeaders['link'][0], '; rel="'.$type.'"') > -1) {
566-
$headerLinks = explode(',', $responseHeaders['link'][0]);
565+
var_dump($responseHeaders['link']);
566+
if (stristr($responseHeaders['link'], '; rel="'.$type.'"') > -1) {
567+
$headerLinks = explode(',', $responseHeaders['link']);
567568
foreach ($headerLinks as $headerLink) {
568569
if (stristr($headerLink, '; rel="'.$type.'"') === -1) {
569570
continue;
@@ -589,15 +590,25 @@ public function getNextLink(){
589590
return $this->nextLink;
590591
}
591592

593+
public function getUrlParams($url) {
594+
if ($url) {
595+
$parts = parse_url($url);
596+
return $parts['query'];
597+
}
598+
return '';
599+
}
600+
592601
public function getNextPageParams(){
593602
$nextPageParams = [];
594-
parse_str($this->getNextLink(), $nextPageParams);
603+
$nextPageLink =
604+
605+
parse_str($this->getUrlParams($this->getNextLink()), $nextPageParams);
595606
return $nextPageParams;
596607
}
597608

598609
public function getPrevPageParams(){
599610
$nextPageParams = [];
600-
parse_str($this->getPrevLink(), $nextPageParams);
611+
parse_str($this->getUrlParams($this->getPrevLink()), $nextPageParams);
601612
return $nextPageParams;
602613
}
603614
}

0 commit comments

Comments
 (0)