Questions tagged [join]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
13
votes
1answer
29k views

How to use group by in magento collection with join query

In module's admin grid I am using this code to get collection and group them by customer id $collection = Mage::getModel('referafriend/statistics')->getCollection(); $collection->getSelect()-&...
7
votes
1answer
4k views

Magento 2:SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'entity_id' in where clause is ambiguous

I have added a new column in customer grid using the following: app/code/Company/Module/etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
6
votes
1answer
1k views

Order by joined custom table

I've got a productcollection, which i joined a custom table to. I'd now like to order the collection on the custom joined table row "custom_row_value". I've tried the below method, but this does not ...
6
votes
1answer
4k views

Best sellers block from joining product collection with the monthly bestseller aggregation

So we're trying to implement a best sellers block on the Magento homepage using this example provided by Inchoo... Only problem is though, when I dissect the SQL select query, which is the below, the ...
5
votes
1answer
10k views

How to join custom table with product collection

I have created a custom vendor module. How can i get vendor name along with product collection?. Mine have a vendor attribute whose values comes from vendor module. I tried $collection = Mage::...
5
votes
2answers
3k views

Join 3 tables in Magento 2

I am new to magento 2, And want to join 4 tables. TABLE 1) market_p_userdata (columns -> seller_id, image) TABLE 2) market_product (columns -> seller_id, magepro_id) TABLE 3) ...
5
votes
1answer
6k views

Understanding setSelect()->join Need to join two custom collections

I am confused understanding the correct usage of $collection->getSelect()->join(... to bring two custom model resources together. I tried following other examples using the getSelect method. I ...
5
votes
2answers
947 views

Joining table to collection doesn't work but getData shows joined fields

The problem I have joined the category product list collection (getLoadedProductCollection from Mage_Catalog_Block_Product_List) with a custom table. Because this collection is loaded from ...
4
votes
3answers
4k views

How to join a calculated column from a table to collection

I have a table name stat_customer look like this: I want to add a column page_view to customer collection to show at grid page. page_view is total page view of product page for each customer. My SQL ...
4
votes
4answers
8k views

How to Get Distinct Entries from Joined Tables Through Join()

This doubt aroused when I am answering one of the question that posted here. But this question is not a continuation of that question, rather a general doubt. Basically I need to get log-customer ...
4
votes
1answer
3k views

How to join a collection with a query

I have a table represented in backend with two rendered fields, but when I try to make a CSV export from this grid, those two fields are not included. So I tried to make a join from the initial ...
3
votes
2answers
1k views

Magento 2 - How use join between sales_order and sales_order_item table

How to use Join in Magento2. i want to get customer_firstname from sales_order table and price , qty_ordered columns from sales_order_item table where sales_order.entity_id=sales_order_item.order_id ...
3
votes
1answer
3k views

Custom admin grid filter - error when searching joined column

I have a custom grid with columns created by joining a flat table to the customer collection. Everything works fine except when i try to filter the list using any of the column added from the flat ...
3
votes
1answer
2k views

Cannot sorting joined column in Magento Grid

I have joined 2 columns to customer grid, I can make them filterable but I don't know how to make them sortable. Here is my _prepareCollection function: protected function _prepareCollection() { ...
3
votes
1answer
496 views

How to convert raw PHP Join Query into Magento Join Query

How to convert raw php LEFT JOIN query in to magento query? What is Magentos syntax for? Here is my query: SELECT fieldsmanager_orders.value,sales_flat_order_address.entity_id FROM ...
3
votes
2answers
5k views

How to join a table with a Magento 2 repository

I am trying to extend inventory stock items by joining my own table with added information. When the product page is loaded it gets the stock item via StockItemRepository::getList($criteria). So I ...
3
votes
0answers
52 views

How to join multiple repositories

Suppose if I want to join product repository and orderItem repository, then how can do that? There is way to join multiple collections (methods like join, joinRight, joinLeft, ...), how to do same ...
3
votes
1answer
853 views

How to sort products by bestsellers (e.g. by sales) in Magento 2

these days I've faced a problem: I needed to to sort products by sales. So, first of all I decided to add this field to collection of products and the order it using method $collection->setOrder(). ...
2
votes
1answer
8k views

how to join three tables on every time when model load

I want to join three tables on every time when model load (for example on edit from page, on grid page in admin and detail page in front-end etc... ) in my custom module. can you please let me know ...
2
votes
2answers
2k views

Using an expression as a join

I have a query that I'm trying to use in an admin grid. It is summing the values in another table, in a subselect, and then joining on that table: SELECT main_table.*, author_debit_amount FROM ...
2
votes
2answers
4k views

Nested/subquery select in a join query

I have this working SQL query : select prd_brand.* from prd_brand inner join ( select distinct value from catalog_product_entity_int where rowid in (select rowid from ...
2
votes
2answers
2k views

Join Collection to table

So, I have subscribers collection: $subscribersCollection = Mage::getModel('newsletter/subscriber')->getCollection(); I want to join customer collection to it by email, so I did next: $...
2
votes
1answer
1k views

How to use a subquery while performing left join in magento

I want my query to filter only distinct product_id from the table catalog_category_product . The raw sql query goes like this : SELECT * FROM catalog_category_entity AS catalog_category_table LEFT ...
2
votes
2answers
583 views

Magento 2 - the grid columns are empty after joining table

I have two tables: A & B . I want to display two columns from table B in my grid. The column names are: Price (See img) and Status(which is missing from the img, but it's there :) ). In my ...
2
votes
1answer
1k views

Join eav attributes

Im trying to join attributes in my collection on my grid view of "supply needs" from my ERP (Erp boost my shop) The collection is loaded like this: $collection = Mage::getModel('Purchase/SupplyNeeds'...
2
votes
1answer
689 views

Foreach loop taking long time in magento product collection with limit

I have following code in which I have join product collection with sales order item table. this query takes fraction of a seconds to execute but foreach loop after that takes around half minute while ...
2
votes
0answers
651 views

SQL UPDATE with JOIN

Knowing I want Magento assemble and execute the following query : UPDATE `catalog_product_entity_media_gallery_value` AS `tGV` INNER JOIN `catalog_product_entity_media_gallery` AS `tG` ON `tG`...
1
vote
1answer
3k views

Need help with collection joinField() - Magento 2

Can anyone describe how to use joinField() method of collection (Magento\Eav\Model\Entity\Collection\AbstractCollection). I actually don't know what means each argument: public function joinField($...
1
vote
1answer
24 views

I’m looking for a way to find all orders that the “bill to” and “ship to” are different states and the dollar amounts associated with those orders

I know that I could check in the sales flat tables. I would probably have to look into sales_flat_order and sales_flat_order_address and do a SQL join. Additionally, the entity_id would be the ...
1
vote
1answer
209 views

Fatal error on `prepareColumns` method

Getting fatal error on Item (Mage_Catalog_Model_Product) with the same id "223" already exist Here 223 is my product Id My _prepareCollection() Method protected function _prepareCollection() { ...
1
vote
1answer
1k views

Determine if collection has an attribute in the select

I want to join a custom field to a product collection, and the field I'm using to join it on is a custom attribute. My observer method is currently doing this: # Event: global/...
1
vote
1answer
3k views

Admin Grid Filtering on Joined Column

I have an admin grid that I'm using, and pulling in custom model and displaying. Everything works fine, and all columns can filter/sort, except when I try to use a column that is not inherent to my ...
1
vote
1answer
405 views

Join two tables cms/page and cms/page_store

I will try get all pages assign to the website with name $collection = Mage::getModel('cms/page')->getCollection(); $collection->getSelect() ->join( array('cps' => $collection-&...
1
vote
1answer
486 views

MySQL Ambiguity Error on Custom Collection Multiple Attribute Join

I have a custom collection which pretty much only consists of product entity ids. I'd like to display a lot of other attributes from EAV tables, but these are all stored in the value column, which ...
1
vote
1answer
169 views

How to join three tables for filteration?

I am applying filter on order collection. I am stuck in a situation, I have added a custom attribute to "customer address". that is in table "customer_address_entity_varchar", now I have to join ...
1
vote
0answers
20 views

How to use “CASE WHEN” on select join magento 2

I try to get shipping postcode, shipping city, billing postcode, billing city of order, join to table sales_order_address, but i can't use "CASE WHEN" on Join. Can someone help me, please. ...
1
vote
0answers
36 views

Join attribute lable in product collection

I'm creating one grid which will have to below columns like SKU,Name and Color (Attribute) So to achieve this We've to join color data to collection for that I've added _initSelect to collection ...
1
vote
2answers
124 views

magento2 join query

I want to join the main table code with the product_options value giftcard_created_codes My query till now $this->getSelect()->joinLeft(['secondTable' => $this->getTable('...
1
vote
1answer
513 views

How to get collection from two tables and show in Admin grid using Union query Magento2.2.5?

I want to show two table values in Admin grid using UI Component (which has no relation) so using union query it can be achieved. How to get the collection from two tables? Table structure 1 Table ...
1
vote
0answers
158 views

get join table's all rows with collection magento2

I am fetching a collection (of user table), that is retrieving correctly. Now I have one more table (ex.- address) that has multiple row related collection table primary key. I want to fetch them all ...
1
vote
0answers
262 views

Magento 2 Join two table and dispaly value in grid

public function addCustomerData($filter = null) { $customersSelect = $this->customerResource->getConnection()->select(); $customersSelect->from( ['customer' ...
1
vote
1answer
108 views

How to use collections or joins in Magento 2

I'm trying to filter by order_item to get a list of orders. Get all orders where an order item has a price greater than 5. How would this be done? Collections? Joins?
1
vote
0answers
487 views

How to get parent product collection from child product collection

I have a simple product collection and I want to get a collection of parent products from the child product collection. $child_collection = Mage::getResourceModel('catalog/product_collection') -&...
1
vote
0answers
427 views

How to add invoice column to payment grid

I have a custom grid that show all information of save CC method per order. protected function _prepareCollection() { $collection = Mage::getModel('sales/order_payment')->...
1
vote
1answer
1k views

Join to get thumbnail from sales order item - add column to order grid [duplicate]

I'm trying to use an observer to add the thumbnail path to the sales order grid collection - the purpose of this is to add an extra column to the order grid which displays the sales item images. I've ...
0
votes
1answer
11k views

catalog_product_collection_load_before and getLoadedProductCollection

I have a strange problem, which gives me the feeling i missed some concept: In an observer triggered via event dispatch <catalog_product_collection_load_before> i fetch the collection and do a ...
0
votes
1answer
138 views

Magento 2: What's best way to convert MySql to Magento

I've below MySql query, I would like to change use it in Magento format. How can i do that ? SELECT customer_entity_varchar.value, customer_entity_text.value from customer_entity INNER JOIN ...
0
votes
1answer
537 views

Magento2 use Multiple LIKE operator in Join Query

I have used Join query,in which i'm able to fetch only one row by below query where $productId = 10 $collection->getSelect()->where('paproduct.product_id = (?)', $productId); I want to use ...
0
votes
1answer
525 views

Remove the single quotes from join

I have this magento code : $subquery = new \Zend_Db_Expr('SELECT DISTINCT value from catalog_product_entity_int where row_id in (select row_id from catalog_product_entity_int where attribute_id = 97 ...
0
votes
1answer
3k views

Issues with join / joinField / joinAttribute (undefined method)

I'm trying to join a category with an event. Here's what I have so far: <?php $rootCategoryId = Mage::app()->getStore()->getRootCategoryId(); $categoryModel = Mage::getModel('catalog/...