krylach / ymlparser
YML (Yandex Market Language) 解析器
v1.0.1
2024-01-16 17:37 UTC
Requires
- php: >=7.4
- illuminate/collections: >=8.0
README
使用包管理器composer安装YML解析器。
composer require krylach/ymlparser
用法
use Krylach\YMLParser\YML; $yml = new YML($path); $yml = new YML("./ymldocument.xml"); $yml = $yml->parse();
商店
$shop = $yml->getShop(); $shop->getName(); $shop->getUrl(); $shop->getPhone(); $shop->getCompany();
分类
$categories = $yml->getCategories(); foreach ($categories as $category) { $id = $category->getId(); $parentId = $category->getParentId(); $name = $category->getName(); }
商品
$offers = $yml->getOffers(); foreach ($offers as $offer) { $pictures = $offer->getPictures(); $parameters = $offer->getParameters(); }
商品图片
foreach ($pictures as $picture) { $url = $picture->getUrl(); }
商品参数
foreach ($parameters as $parameter) { $name = $parameter->getName(); $value = $parameter->getValue(); }
其他属性参数
您可以从YML文档中的商品中获取任何指定的值。例如
foreach ($offers as $offer) { $name = $offer->getName(); $categoryId = $offer->getCategoryId(); $price = $offer->getPrice(); $vendorCode = $offer->getVendorCode(); $description = $offer->getDescription(); $available = $offer->getAvailable(); $currencyId = $offer->getCurrencyId(); }
货币
foreach ($currencies as $currency) { $id = $currency->getId(); $rate = $currency->getRate(); }