{"id":24525897,"url":"https://github.com/vitalybaev/php-google-merchant-feed","last_synced_at":"2025-04-05T08:06:07.307Z","repository":{"id":21429754,"uuid":"92728129","full_name":"vitalybaev/php-google-merchant-feed","owner":"vitalybaev","description":"PHP package, that generates Google Merchant XML Feed","archived":false,"fork":false,"pushed_at":"2024-03-07T09:30:51.000Z","size":40,"stargazers_count":82,"open_issues_count":11,"forks_count":32,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-03-15T05:11:34.368Z","etag":null,"topics":["google-merchant","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vitalybaev.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-29T10:07:21.000Z","updated_at":"2024-06-18T14:04:48.619Z","dependencies_parsed_at":"2024-06-18T14:04:48.155Z","dependency_job_id":"95eecf70-df25-4f66-a514-0c18bb17796e","html_url":"https://github.com/vitalybaev/php-google-merchant-feed","commit_stats":{"total_commits":33,"total_committers":11,"mean_commits":3.0,"dds":0.6060606060606061,"last_synced_commit":"b0bcb7290e495c12a2038c6aa8db2a3782dc9f43"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalybaev%2Fphp-google-merchant-feed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalybaev%2Fphp-google-merchant-feed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalybaev%2Fphp-google-merchant-feed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitalybaev%2Fphp-google-merchant-feed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitalybaev","download_url":"https://codeload.github.com/vitalybaev/php-google-merchant-feed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305933,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-merchant","php"],"created_at":"2025-01-22T05:29:12.902Z","updated_at":"2025-04-05T08:06:07.283Z","avatar_url":"https://github.com/vitalybaev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Merchant feed generator for PHP\n\n[![Build Status](https://travis-ci.org/vitalybaev/php-google-merchant-feed.svg?branch=master)](https://travis-ci.org/vitalybaev/php-google-merchant-feed)\n\n## Installation\n\nInstall the package through [Composer](http://getcomposer.org/). \n\nRun the Composer require command from the Terminal:\n\n    composer require vitalybaev/google-merchant-feed\n\n\n## Example\n\n```php\nuse Vitalybaev\\GoogleMerchant\\Feed;\nuse Vitalybaev\\GoogleMerchant\\Product;\nuse Vitalybaev\\GoogleMerchant\\Product\\Shipping;\nuse Vitalybaev\\GoogleMerchant\\Product\\Availability\\Availability;\n\n// Create feed object\n$feed = new Feed(\"My awesome store\", \"https://example.com\", \"My awesome description\");\n\n// Put products to the feed ($products - some data from database for example)\nforeach ($products as $product) {\n    $item = new Product();\n    \n    // Set common product properties\n    $item-\u003esetId($product-\u003eid);\n    $item-\u003esetTitle($product-\u003etitle);\n    $item-\u003esetDescription($product-\u003edescription);\n    $item-\u003esetLink($product-\u003egetUrl());\n    $item-\u003esetImage($product-\u003egetImage());\n    if ($product-\u003eisAvailable()) {\n        $item-\u003esetAvailability(Availability::IN_STOCK);\n    } else {\n        $item-\u003esetAvailability(Availability::OUT_OF_STOCK);\n    }\n    $item-\u003esetPrice(\"{$product-\u003eprice} USD\");\n    $item-\u003esetGoogleCategory($product-\u003ecategory_name);\n    $item-\u003esetBrand($product-\u003ebrand-\u003ename);\n    $item-\u003esetGtin($product-\u003ebarcode);\n    $item-\u003esetCondition('new');\n    \n    // Some additional properties\n    $item-\u003esetColor($product-\u003ecolor);\n    $item-\u003esetSize($product-\u003esize);\n\n    // Shipping info\n    $shipping = new Shipping();\n    $shipping-\u003esetCountry('US');\n    $shipping-\u003esetRegion('CA, NSW, 03');\n    $shipping-\u003esetPostalCode('94043');\n    $shipping-\u003esetLocationId('21137');\n    $shipping-\u003esetService('UPS Express');\n    $shipping-\u003esetPrice('1300 USD');\n    $item-\u003esetShipping($shipping);\n\n    // Set a custom shipping label and weight (optional)\n    $item-\u003esetShippingLabel('ups-ground');\n    $item-\u003esetShippingWeight('2.14');\n\n    // Set a custom label (optional)\n    $item-\u003esetCustomLabel('Some Label 1', 0);\n    $item-\u003esetCustomLabel('Some Label 2', 1);\n    \n    // Add this product to the feed\n    $feed-\u003eaddProduct($item);\n}\n\n// Here we get complete XML of the feed, that we could write to file or send directly\n$feedXml = $feed-\u003ebuild();\n\n```\n\n## Working with attributes\n`Product` class provides several methods for managing various attributes. But it doesn't cover all Google Merchant attributes. In case of nonexistent methods you should use one of the following:\n\n1. `$product-\u003esetAttribute($attributeName, $attributeValue, $isCData = false)` - sets attribute. Replaces old attribute if it existed. \n2. `$product-\u003eaddAttribute($attributeName, $attributeValue, $isCData = false)` - adds one more attribute's value. For example feed can have multiple `additional_image_link` attributes.\n\n## TO-DO\n* Cover all Google Merchant feed properties\n* More tests\n* Your feedback?\n\n## License\n\n```\nThe MIT License\n\nCopyright (c) 2016 Vitaly Baev. vitalybaev.ru\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitalybaev%2Fphp-google-merchant-feed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitalybaev%2Fphp-google-merchant-feed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitalybaev%2Fphp-google-merchant-feed/lists"}