Skip to content

Commit

Permalink
List and show store
Browse files Browse the repository at this point in the history
  • Loading branch information
caothu159 committed Jul 26, 2024
1 parent a6ca41d commit d58e4c6
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/Builders/StoreViewsBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

/*
* @copyright © 2019 Dxvn, Inc.
*
* @author Tran Ngoc Duc <ductn@diepxuan.com>
* @author Tran Ngoc Duc <caothu91@gmail.com>
*
* @lastupdate 2024-07-25 21:20:56
*/

namespace Diepxuan\Magento\Builders;

use Diepxuan\Magento\Models\StoreViews;
use Illuminate\Support\Collection;

class StoreViewsBuilder extends Builder
{
protected $entity = StoreViews::ENTITY;
protected $model = StoreViews::class;

protected function parseResponse($response): Collection
{
$fetchedItems = collect($response);
$items = collect([]);

foreach ($fetchedItems as $index => $item) {
/** @var StoreViews $model */
$model = new $this->model($this->request, $item);

$items->push($model);
}

return $items;
}
}
8 changes: 7 additions & 1 deletion src/Magento.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
* @author Tran Ngoc Duc <ductn@diepxuan.com>
* @author Tran Ngoc Duc <caothu91@gmail.com>
*
* @lastupdate 2024-06-17 21:45:19
* @lastupdate 2024-07-25 21:22:21
*/

namespace Diepxuan\Magento;

use Diepxuan\Magento\Builders\CategoryBuilder;
use Diepxuan\Magento\Builders\ProductBuilder;
use Diepxuan\Magento\Builders\StoreViewsBuilder;
use Diepxuan\Magento\Builders\StoreWebsitesBuilder;
use Diepxuan\Magento\Http\Request;
use Diepxuan\Magento\Utils\Oauth1;
Expand Down Expand Up @@ -42,6 +43,11 @@ public static function store_websites(): StoreWebsitesBuilder
return new StoreWebsitesBuilder(self::initOAuthRequest());
}

public static function store_views(): StoreViewsBuilder
{
return new StoreViewsBuilder(self::initOAuthRequest());
}

/**
* Initial OAuth Request.
*
Expand Down
22 changes: 22 additions & 0 deletions src/Models/StoreViews.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

/*
* @copyright © 2019 Dxvn, Inc.
*
* @author Tran Ngoc Duc <ductn@diepxuan.com>
* @author Tran Ngoc Duc <caothu91@gmail.com>
*
* @lastupdate 2024-07-25 21:19:12
*/

namespace Diepxuan\Magento\Models;

#[\AllowDynamicProperties]
class StoreViews extends Model
{
public const ENTITY = 'store/storeViews';
protected $entity = 'store/storeViews';
protected $primaryKey = 'id';
}

0 comments on commit d58e4c6

Please sign in to comment.