item->get('key'); does not work as expected
rabol opened this issue · 1 comments
rabol commented
After runnung the spider like this
$items = Roach::collectSpider(SpainOnAForkSpider::class);
I do
foreach( $items as $item)
{
debug($item->get('json'));
}
result is
null
a dump of $items like this:
^ array:1 [▼
0 => RoachPHP\ItemPipeline\Item {#524 ▼
-data: array:2 [▼
0 => "json"
1 => "{"@context":"https://schema.org","@graph":[{"@type":"Article","@id":"https://spainonafork.com/authentic-spanish-seafood-paella-recipe/#article","isPartOf":{"@id ▶"
]
-dropReason: ""
-dropped: false
}
]
rabol commented
Item was not created correctly in the spider class
this is what I did:
yield $this->item(['json', $json]);
this is correct
yield $this->item(['json' => $json]);