custom table left join with catalog/productAttributes missing when a product is loaded via grouped productsIs it possible to save attribute value per store in custom eav based model?MySQL Ambiguity Error on Custom Collection Multiple Attribute JoinCatalog Product ViewCustom Attribute and value not Appearing in Flat Product table if Attribute is not in…Product Listing,Product Listing,Layered NavigationMagento 2: Join EAV attribute from product attribute set on a custom flat tableJoin eav attributesLeft join on custom collection, to get product name by product IDHow can we set the product-ID instead of the product-name in database on Magento2How can get custom table columns on product listing page using product_id of the custom table
When and what was the first 3D acceleration device ever released?
Why does the 6502 have the BIT instruction?
Riley Rebuses that Share a Common Theme
At what point in European history could a government build a printing press given a basic description?
Is this resistor leaking? If so, is it a concern?
Mother abusing my finances
Would the Geas spell work in a dead magic zone once you enter it?
Why is this Simple Puzzle impossible to solve?
How were these pictures of spacecraft wind tunnel testing taken?
What's the Difference between Two Single-Quotes and One Double-Quote?
Array Stutter Implementation
Would jet fuel for an F-16 or F-35 be producible during WW2?
What are the benefits of cryosleep?
Integrating an absolute function using Mathematica
Should breaking down something like a door be adjudicated as an attempt to beat its AC and HP, or as an ability check against a set DC?
What is the difference between “/private/var/vm” and “/vm”?
Should I disclose a colleague's illness (that I should not know about) when others badmouth him
In general, would I need to season a meat when making a sauce?
analysis of BJT PNP type - why they can use voltage divider?
How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?
Is it ok to put a subplot to a story that is never meant to contribute to the development of the main plot?
How do you say “buy” in the sense of “believe”?
Can a wire having 610-670 THz (frequency of blue light) A.C frequency supply, generate blue light?
Is there a general effective method to solve Smullyan style Knights and Knaves problems? Is the truth table method the most appropriate one?
custom table left join with catalog/product
Attributes missing when a product is loaded via grouped productsIs it possible to save attribute value per store in custom eav based model?MySQL Ambiguity Error on Custom Collection Multiple Attribute JoinCatalog Product ViewCustom Attribute and value not Appearing in Flat Product table if Attribute is not in…Product Listing,Product Listing,Layered NavigationMagento 2: Join EAV attribute from product attribute set on a custom flat tableJoin eav attributesLeft join on custom collection, to get product name by product IDHow can we set the product-ID instead of the product-name in database on Magento2How can get custom table columns on product listing page using product_id of the custom table
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a custom table called flagged_products which lists flagged products like this:
+-----------+------------+---------------------+
| entity_id | product_id | flagged_on |
+-----------+------------+---------------------+
| 1 | 356534 | 2019-03-01 12:45:20 |
| 2 | 654657 | 2019-01-07 05:52:09 |
| 3 | 345477 | 2019-03-23 09:34:07 |
| 4 | 114673 | 2019-04-11 15:45:17 |
+-----------+------------+---------------------+
I want to join this with the catalog/product model to list all the names of the products which have been flagged like this:
+-----------+--------------+---------------------+
| entity_id | product_name | flagged_on |
+-----------+--------------+---------------------+
| 356534 | Product 1 | 2019-03-01 12:45:20 |
| 654657 | Product 2 | 2019-01-07 05:52:09 |
| 345477 | Product 3 | 2019-03-23 09:34:07 |
| 114673 | Product 4 | 2019-04-11 15:45:17 |
+-----------+--------------+---------------------+
However, since the product name is a part of the EAV tables, i'm not really sure how to get this information.
Would appreciate help on how this can be achieved with Magento 1
magento-1.9 database collection catalog eav
New contributor
yd87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I have a custom table called flagged_products which lists flagged products like this:
+-----------+------------+---------------------+
| entity_id | product_id | flagged_on |
+-----------+------------+---------------------+
| 1 | 356534 | 2019-03-01 12:45:20 |
| 2 | 654657 | 2019-01-07 05:52:09 |
| 3 | 345477 | 2019-03-23 09:34:07 |
| 4 | 114673 | 2019-04-11 15:45:17 |
+-----------+------------+---------------------+
I want to join this with the catalog/product model to list all the names of the products which have been flagged like this:
+-----------+--------------+---------------------+
| entity_id | product_name | flagged_on |
+-----------+--------------+---------------------+
| 356534 | Product 1 | 2019-03-01 12:45:20 |
| 654657 | Product 2 | 2019-01-07 05:52:09 |
| 345477 | Product 3 | 2019-03-23 09:34:07 |
| 114673 | Product 4 | 2019-04-11 15:45:17 |
+-----------+--------------+---------------------+
However, since the product name is a part of the EAV tables, i'm not really sure how to get this information.
Would appreciate help on how this can be achieved with Magento 1
magento-1.9 database collection catalog eav
New contributor
yd87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I have a custom table called flagged_products which lists flagged products like this:
+-----------+------------+---------------------+
| entity_id | product_id | flagged_on |
+-----------+------------+---------------------+
| 1 | 356534 | 2019-03-01 12:45:20 |
| 2 | 654657 | 2019-01-07 05:52:09 |
| 3 | 345477 | 2019-03-23 09:34:07 |
| 4 | 114673 | 2019-04-11 15:45:17 |
+-----------+------------+---------------------+
I want to join this with the catalog/product model to list all the names of the products which have been flagged like this:
+-----------+--------------+---------------------+
| entity_id | product_name | flagged_on |
+-----------+--------------+---------------------+
| 356534 | Product 1 | 2019-03-01 12:45:20 |
| 654657 | Product 2 | 2019-01-07 05:52:09 |
| 345477 | Product 3 | 2019-03-23 09:34:07 |
| 114673 | Product 4 | 2019-04-11 15:45:17 |
+-----------+--------------+---------------------+
However, since the product name is a part of the EAV tables, i'm not really sure how to get this information.
Would appreciate help on how this can be achieved with Magento 1
magento-1.9 database collection catalog eav
New contributor
yd87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have a custom table called flagged_products which lists flagged products like this:
+-----------+------------+---------------------+
| entity_id | product_id | flagged_on |
+-----------+------------+---------------------+
| 1 | 356534 | 2019-03-01 12:45:20 |
| 2 | 654657 | 2019-01-07 05:52:09 |
| 3 | 345477 | 2019-03-23 09:34:07 |
| 4 | 114673 | 2019-04-11 15:45:17 |
+-----------+------------+---------------------+
I want to join this with the catalog/product model to list all the names of the products which have been flagged like this:
+-----------+--------------+---------------------+
| entity_id | product_name | flagged_on |
+-----------+--------------+---------------------+
| 356534 | Product 1 | 2019-03-01 12:45:20 |
| 654657 | Product 2 | 2019-01-07 05:52:09 |
| 345477 | Product 3 | 2019-03-23 09:34:07 |
| 114673 | Product 4 | 2019-04-11 15:45:17 |
+-----------+--------------+---------------------+
However, since the product name is a part of the EAV tables, i'm not really sure how to get this information.
Would appreciate help on how this can be achieved with Magento 1
magento-1.9 database collection catalog eav
magento-1.9 database collection catalog eav
New contributor
yd87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
yd87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
yd87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked May 21 at 13:12
yd87yd87
1033
1033
New contributor
yd87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
yd87 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
If you want to try the "Magento way", you could try something like :
$flaggedProducts = Mage::getModel('your_module/your_model')->getCollection();
// Join with product table
$flaggedProducts->getSelect()->joinLeft(
array('cp' => $flaggedProducts->getTable('catalog/product'),
'cp.entity_id=main_table.product_id',
array(
'product_entity_id' => new Zend_Db_Expr('cp.entity_id')
)
);
// Join to get the name
$nameAttribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'name');
$nameTable = $nameAttribute->getBackendTable();
$nameId = $nameAttribute->getAttributeId();
// Get default store name value
$flaggedProducts->getSelect()->joinLeft(
array('nt' => $nameTable),
'nt.attribute_id=' . $nameId . ' AND nt.entity_id = cp.entity_id AND nt.store_id = 0',
array(
'product_name' => new Zend_Db_Expr('nt.value')
)
);
If you just want to do some sql query, maybe something like :
SELECT fp.*, cpev_name.value FROM flagged_products AS fp
LEFT JOIN catalog_product_entity_varchar AS cpev_name
ON fp.product_id = cpev_name.entity_id AND cpev_name.attribute_id = 'put-here-the-id-of-the-attribute-name'
AND cpev_name.store_id = 0
add a comment |
Please try this query it will give you expected output.
select fp.*, cpev.value as product_name from flagged_products as fp
left JOIN catalog_product_entity_varchar as cpev on cpev.entity_id = fp.product_id
WHERE cpev.attribute_id=71
Let me know if you have any query.
add a comment |
<?php
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->getSelect()
->joinLeft(
array('flagged_products' => $this->getTable('flagged_products')),
'e.entity_id = flagged_products.product_id'
);
I want theflagged_productstable to be on the left.
– yd87
May 21 at 14:26
Code updated, please check
– Saphal Jha
May 21 at 16:11
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
yd87 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f275485%2fcustom-table-left-join-with-catalog-product%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to try the "Magento way", you could try something like :
$flaggedProducts = Mage::getModel('your_module/your_model')->getCollection();
// Join with product table
$flaggedProducts->getSelect()->joinLeft(
array('cp' => $flaggedProducts->getTable('catalog/product'),
'cp.entity_id=main_table.product_id',
array(
'product_entity_id' => new Zend_Db_Expr('cp.entity_id')
)
);
// Join to get the name
$nameAttribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'name');
$nameTable = $nameAttribute->getBackendTable();
$nameId = $nameAttribute->getAttributeId();
// Get default store name value
$flaggedProducts->getSelect()->joinLeft(
array('nt' => $nameTable),
'nt.attribute_id=' . $nameId . ' AND nt.entity_id = cp.entity_id AND nt.store_id = 0',
array(
'product_name' => new Zend_Db_Expr('nt.value')
)
);
If you just want to do some sql query, maybe something like :
SELECT fp.*, cpev_name.value FROM flagged_products AS fp
LEFT JOIN catalog_product_entity_varchar AS cpev_name
ON fp.product_id = cpev_name.entity_id AND cpev_name.attribute_id = 'put-here-the-id-of-the-attribute-name'
AND cpev_name.store_id = 0
add a comment |
If you want to try the "Magento way", you could try something like :
$flaggedProducts = Mage::getModel('your_module/your_model')->getCollection();
// Join with product table
$flaggedProducts->getSelect()->joinLeft(
array('cp' => $flaggedProducts->getTable('catalog/product'),
'cp.entity_id=main_table.product_id',
array(
'product_entity_id' => new Zend_Db_Expr('cp.entity_id')
)
);
// Join to get the name
$nameAttribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'name');
$nameTable = $nameAttribute->getBackendTable();
$nameId = $nameAttribute->getAttributeId();
// Get default store name value
$flaggedProducts->getSelect()->joinLeft(
array('nt' => $nameTable),
'nt.attribute_id=' . $nameId . ' AND nt.entity_id = cp.entity_id AND nt.store_id = 0',
array(
'product_name' => new Zend_Db_Expr('nt.value')
)
);
If you just want to do some sql query, maybe something like :
SELECT fp.*, cpev_name.value FROM flagged_products AS fp
LEFT JOIN catalog_product_entity_varchar AS cpev_name
ON fp.product_id = cpev_name.entity_id AND cpev_name.attribute_id = 'put-here-the-id-of-the-attribute-name'
AND cpev_name.store_id = 0
add a comment |
If you want to try the "Magento way", you could try something like :
$flaggedProducts = Mage::getModel('your_module/your_model')->getCollection();
// Join with product table
$flaggedProducts->getSelect()->joinLeft(
array('cp' => $flaggedProducts->getTable('catalog/product'),
'cp.entity_id=main_table.product_id',
array(
'product_entity_id' => new Zend_Db_Expr('cp.entity_id')
)
);
// Join to get the name
$nameAttribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'name');
$nameTable = $nameAttribute->getBackendTable();
$nameId = $nameAttribute->getAttributeId();
// Get default store name value
$flaggedProducts->getSelect()->joinLeft(
array('nt' => $nameTable),
'nt.attribute_id=' . $nameId . ' AND nt.entity_id = cp.entity_id AND nt.store_id = 0',
array(
'product_name' => new Zend_Db_Expr('nt.value')
)
);
If you just want to do some sql query, maybe something like :
SELECT fp.*, cpev_name.value FROM flagged_products AS fp
LEFT JOIN catalog_product_entity_varchar AS cpev_name
ON fp.product_id = cpev_name.entity_id AND cpev_name.attribute_id = 'put-here-the-id-of-the-attribute-name'
AND cpev_name.store_id = 0
If you want to try the "Magento way", you could try something like :
$flaggedProducts = Mage::getModel('your_module/your_model')->getCollection();
// Join with product table
$flaggedProducts->getSelect()->joinLeft(
array('cp' => $flaggedProducts->getTable('catalog/product'),
'cp.entity_id=main_table.product_id',
array(
'product_entity_id' => new Zend_Db_Expr('cp.entity_id')
)
);
// Join to get the name
$nameAttribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'name');
$nameTable = $nameAttribute->getBackendTable();
$nameId = $nameAttribute->getAttributeId();
// Get default store name value
$flaggedProducts->getSelect()->joinLeft(
array('nt' => $nameTable),
'nt.attribute_id=' . $nameId . ' AND nt.entity_id = cp.entity_id AND nt.store_id = 0',
array(
'product_name' => new Zend_Db_Expr('nt.value')
)
);
If you just want to do some sql query, maybe something like :
SELECT fp.*, cpev_name.value FROM flagged_products AS fp
LEFT JOIN catalog_product_entity_varchar AS cpev_name
ON fp.product_id = cpev_name.entity_id AND cpev_name.attribute_id = 'put-here-the-id-of-the-attribute-name'
AND cpev_name.store_id = 0
edited May 21 at 13:42
answered May 21 at 13:34
Julien LoizeletJulien Loizelet
992414
992414
add a comment |
add a comment |
Please try this query it will give you expected output.
select fp.*, cpev.value as product_name from flagged_products as fp
left JOIN catalog_product_entity_varchar as cpev on cpev.entity_id = fp.product_id
WHERE cpev.attribute_id=71
Let me know if you have any query.
add a comment |
Please try this query it will give you expected output.
select fp.*, cpev.value as product_name from flagged_products as fp
left JOIN catalog_product_entity_varchar as cpev on cpev.entity_id = fp.product_id
WHERE cpev.attribute_id=71
Let me know if you have any query.
add a comment |
Please try this query it will give you expected output.
select fp.*, cpev.value as product_name from flagged_products as fp
left JOIN catalog_product_entity_varchar as cpev on cpev.entity_id = fp.product_id
WHERE cpev.attribute_id=71
Let me know if you have any query.
Please try this query it will give you expected output.
select fp.*, cpev.value as product_name from flagged_products as fp
left JOIN catalog_product_entity_varchar as cpev on cpev.entity_id = fp.product_id
WHERE cpev.attribute_id=71
Let me know if you have any query.
answered May 21 at 13:36
poojan sharmapoojan sharma
3426
3426
add a comment |
add a comment |
<?php
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->getSelect()
->joinLeft(
array('flagged_products' => $this->getTable('flagged_products')),
'e.entity_id = flagged_products.product_id'
);
I want theflagged_productstable to be on the left.
– yd87
May 21 at 14:26
Code updated, please check
– Saphal Jha
May 21 at 16:11
add a comment |
<?php
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->getSelect()
->joinLeft(
array('flagged_products' => $this->getTable('flagged_products')),
'e.entity_id = flagged_products.product_id'
);
I want theflagged_productstable to be on the left.
– yd87
May 21 at 14:26
Code updated, please check
– Saphal Jha
May 21 at 16:11
add a comment |
<?php
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->getSelect()
->joinLeft(
array('flagged_products' => $this->getTable('flagged_products')),
'e.entity_id = flagged_products.product_id'
);
<?php
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('name')
->getSelect()
->joinLeft(
array('flagged_products' => $this->getTable('flagged_products')),
'e.entity_id = flagged_products.product_id'
);
edited May 21 at 16:11
answered May 21 at 13:32
Saphal JhaSaphal Jha
1,167616
1,167616
I want theflagged_productstable to be on the left.
– yd87
May 21 at 14:26
Code updated, please check
– Saphal Jha
May 21 at 16:11
add a comment |
I want theflagged_productstable to be on the left.
– yd87
May 21 at 14:26
Code updated, please check
– Saphal Jha
May 21 at 16:11
I want the
flagged_products table to be on the left.– yd87
May 21 at 14:26
I want the
flagged_products table to be on the left.– yd87
May 21 at 14:26
Code updated, please check
– Saphal Jha
May 21 at 16:11
Code updated, please check
– Saphal Jha
May 21 at 16:11
add a comment |
yd87 is a new contributor. Be nice, and check out our Code of Conduct.
yd87 is a new contributor. Be nice, and check out our Code of Conduct.
yd87 is a new contributor. Be nice, and check out our Code of Conduct.
yd87 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f275485%2fcustom-table-left-join-with-catalog-product%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown