Comments (7)
Hi @solverat
I got your intention here, if the payload is relatively small I'd just put it into the payload
$productRepository->create([
'active' => true, // or $product->active
], $context);
Or
$productRepository->create(array_filter($product->jsonSerialize()), $context);
Will it work in your case? Filtering every null property out seems not a correct approach. For example when you want to set a property back to null then you need to define that property as null.
But feel free to create a PR or just a draft solution then I will take a look if it could be a good idea to add the method, thanks
from shopware-php-sdk.
Hi @vienthuong,
I was thinking about the same thing when it comes to the code generator. I think I'm going to fork this repo and try it out.
We consider psalm rules very ad hoc in this context so having a solid nullability correspondence with the actual Shopware API would be great. I think I might give it a go :)
from shopware-php-sdk.
Hey @vienthuong. It would be nice to have something like toArray()
in Entity
classes.
$product = new ProductEntity();
$product->active = true;
$productRepository->create($product->toArray(), $context);
... which only should return populated fields. I've tried this by using the jsonSerialize
method, but this method of course returns every available property populated with a null
value if not set.
from shopware-php-sdk.
Maybe another one :):
Uploading asset binaries via repository (?) would be nice. In some cases, URLs are not reachable from outside.
from shopware-php-sdk.
@solverat
Hi, sounds like a good idea, I created a new issue here #23
But honestly, I don't 100% get your expectation so can you write a bit more specific in the new ticket? Like why we need it and why it's not possible currently with the SDK :)
Thanks for contribution
from shopware-php-sdk.
Hi @vienthuong,
On my team we use psalm and sometimes it gets a little bit frustrating that all of the properties in entities are nullable/set to null by default. This either generates a lot of null-checking or disabling null checks in psalm altogether. I reckon that "fixing" or adjusting this wouldn't be a breaking change, right? It's a slight annoyance, especially when you don't normally expect a null value in Shopware:
// CurrencyEntity/SDK:
public ?string $symbol = null;
// CurrencyEntity/Shopware:
/**
* @var string
*/
protected $symbol;
from shopware-php-sdk.
Hi @jakub-groncki
Sorry for the late response.
Change the nullable to non nullable is breaking change unfortunately. By default it's all nullable so we can set all the properties with value or null without fatal error. I already considered it in the generator script but for some reason I commented it out so I am not sure that add it back is a safe solution.
https://github.com/vienthuong/shopware-php-sdk/blob/master/script/src/CodeGenerator.php
I'd recommend ignore these psalm rule using some regex pattern if possible. Or feel free to create a MR to update the CodeGenerator if you find it useful :)
from shopware-php-sdk.
Related Issues (20)
- Cant get Transaction and Delivery Status HOT 1
- Don't cache entities HOT 5
- EntityRepository::searchIds does not throw ShopwareSearchResponseException HOT 3
- Does this sdk work with custom entities? HOT 3
- PHP 8.1 compatibility HOT 6
- EntityCollection is returned for empty results HOT 2
- Self signed certificate HOT 1
- GET Requests are not validated correctly HOT 2
- Call to a member function getSource() on null HOT 7
- Connecting properties, categories and tags to product (question) HOT 2
- Dieser Wert sollte nicht leer sein. c1051bb4-d103-4f74-8988-acbcafc7fdc3 HOT 2
- Transaction commit failed because the transaction has been marked for rollback only HOT 5
- Create Order Delivery HOT 2
- SDK version mismatch HOT 1
- Document download not possible
- The resource owner or authorization server denied the request. Access token could not be verified. HOT 7
- Add support for criteria in SyncService / SyncPayload
- Allowed memory size exhausted HOT 3
- OrderReturnLineItemEntity is missing (part of Shopware Commercial plugin)
- dynamic properties and package versioning HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shopware-php-sdk.