I have created ui component and it works fine, I added data provider file and customized my getData function:-

public function getData() {
        if (!$this->getCollection()->isLoaded()) {

        $this->getCollection()->getSelect()->joinLeft(array('qrcode' => $this->_resource->getTableName('w3solver_qrcode')),
                                               'e.entity_id = qrcode.product_id');

        // echo $this->getCollection()->getSelect()->__toString();
        // exit();

        $items = $this->getCollection()->toArray();

        echo "<pre>";
        return [
            'totalRecords' => $this->getCollection()->getSize(),
            'items' => array_values($items),

When I try to print collection query it gives me correct output but $items is not giving me fields from second table. Can anyone help mw and let me know why I am not getting field from second table.

  • Use only join instead of joinLeft – Prince Patel May 3 '17 at 9:37
  • put your collection join query before if (!$this->getCollection()->isLoaded()) { $this->getCollection()->load(); } – Minesh Patel May 3 '17 at 9:49
  • I have tried those step but it did not work – arushi May 3 '17 at 10:25
  • @PrincePatel when my requirement is to use leftjoin then why will i go for join only. – arushi May 3 '17 at 10:26
  • I have done it, toArray() is a function created in core file which is responsible for only fetching column from first table, don't know why but I just replaced it by my $this->getCollection()->getData(); and it works – arushi May 3 '17 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.