[ create a new paste ] login | about

Link: http://codepad.org/IOsxm9qW    [ raw code | fork ]

PHP, pasted on Jun 19:
<?php

namespace Namespace\Custom\Model\ResourceModel;


use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class Custom extends AbstractDb
{

    /**
     * Resource initialization
     *
     * @return void
     */
    protected function _construct()
    {
        $this->_init('namespace_custom', 'custom_id');
    }

    public function addRelations($data)
    {
        $this->getConnection()
            ->insertMultiple('namespace_customtable', $data);
    }

    public function getAssociatedProductIds($customId)
    {
        $select = $this->getConnection()->select();

        $select->from(
            ['cp' => 'namespace_customtable'],
            'product_id'
        )
            ->where('custom_id=?', $customId);

        return $this->getConnection()->fetchCol($select);
    }
}


Create a new paste based on this one


Comments: