Change the Date of a Review in Magento - magento

Magento reviews follow this format:-
Summary
Body of Review
Date of Review
I need to change the date of the review to a custom date.
Please could somebody guide me on how to go about doing this? I have tried editing the review in the back-end, but the only sections I can change are the Summary and the Body of the review.
If you could let me know where in the database I should change, I'd really appreciate it. Or, if there is a way to change this in the back-end, without installing an extension, that'd be really awesome.

Preface
The Magento Admin backend does not have a place to edit the date of a product review. You must do this directly in the SQL database or programmatically.
The following instructions will help you change it directly in the SQL database.
1.) Find The Review ID
Login to your Magento backend Admin area and go here in the menu:
Magento Admin >> Catalog >> Reviews and Ratings >> Customer Reviews >> All Reviews
In the resulting table of all reviews, find the single review you want to change the date for. Do not click into the review because the ID is only shown in the table of all reviews.
Remember that ID
2.) Change the Date in the Database
I used PhpMyAdmin to get access to my Magento SQL database. You can use whatever SQL Management Platform suits you.
Login to your SQL database and navigate the the table named only 'review'.
In that table you will see a column called 'review_id'.
Find the row in the 'review.review_id' column that matches the ID of the review you want to change the Magento date for.
Click 'Edit' on that row and change the 'created_at' value of it.
Save your changes to the row by clicking 'Go'.
You're done.
Check Magento to make sure it displays the updated date.
Helpful Hints
The date value in 'created_at' must be in the format of an SQL date-time. This is 'YYYY-MM-DD hh:mm:ss'.
Magento is sensitive to timezones. You may need to adjust the date value you use to compensate for this - so it displays the way you want it.
The SQL 'review' table was not listed on my first page of table names in PhpMyAdmin. To find it, I had to click through to the second page of table names.
It is very easy to ruin your website by clicking the wrong things in PhpMyAdmin. So don't screw around in there.

I'd think by directly manipulating the reviews details from Databaes. Although this seems to be discouraged but since it may be one or two records, then creating a custom solution is not feasible.
Running this MySQL to fetch the reviews info from the DB may help you locate the review you are trying to edit.
SELECT
rd.`detail_id`,
rd.`review_id`,
r.`created_at`,
rd.`title`,
rd.`detail`,
rd.`nickname`,
r.`review_id`
FROM
`review_detail` rd
LEFT JOIN review r
ON rd.`review_id` = r.`review_id`
ORDER BY rd.`detail_id` DESC

You can set all Magento 1.x reviews to the order created date us this:
START TRANSACTION;
UPDATE review r INNER JOIN review_detail rd ON (rd.review_id = r.review_id AND r.entity_id = 1) INNER JOIN sales_flat_order_item oi ON (oi.product_id = r.entity_pk_value) INNER JOIN sales_flat_order as o ON (o.entity_id = oi.order_id) SET r.created_at = o.created_at;
SELECT r.review_id, r.created_at as review_date, o.created_at as order_date, o.increment_id, oi.sku FROM review r INNER JOIN review_detail rd ON (rd.review_id = r.review_id AND r.entity_id = 1) INNER JOIN sales_flat_order_item oi ON (oi.product_id = r.entity_pk_value) INNER JOIN sales_flat_order as o ON (o.entity_id = oi.order_id) GROUP BY oi.product_id ORDER BY r.created_at DESC;
COMMIT;
Tested and verified on Magento 1.9.x

Related

How to solve "Warning: triggers are created with compilation errors"?

Hi sorry for the inconvenience of posting a bad question. So below is the edit version of the question:
Purpose of this task:
In this task, I am trying to apply the company’s top client is the one who has purchased the most a discount with 15% discount. One of the requirement before creating this trigger is that - should not hardcode the top client since the top client could change when more purchases are made by other clients. I have created a trigger called TOP_CLIENT and edited the code as below:
AFTER UPDATE ON PURCHASE
BEGIN
SELECT PURCHASENO FROM PURCHASE
WHERE (SELECT MAX(AMOUNT) FROM PURCHASE P
JOIN CLIENT C ON P.PURCHASENO = C.CLIENTNO);
UPDATE PURCHASE
SET AMOUNT = (AMOUNT * 0.85)
END;
/
NOTE THAT:
The table CLIENT and PURCHASE are already created and existed in the database.
Shown errors within this code:
enter image description here
Please comment if any of the above doesn't make sense or have any questions related! Thank you!
First, I suggest adding a numeric DiscountRate column to the Client discount and populating it the applicable rate for any clients who get a discount.
Next, I suggest adding a numeric column called the same DiscountRate to the Purchase table.
With those in place, you can update any purchase row AFTER INSERT OR UPDATE only if the DiscountRate has not yet been applied to the purchase or is not equal to the current client discountrate, depending on your business logic;
DROP TRIGGER TOP_DOSCOUNT;
/
CREATE TRIGGER TOP_DOSCOUNT
AFTER INSERT OR UPDATE ON PURCHASE
FOR EACH ROW
WHEN DiscountRate IS NULL
DECLARE dr PURCHASE.DiscountRate%type;
SELECT nvl(C.DiscountRate,0.0) INTO dr FROM CLIENT C
WHERE PurchaseNo = C.ClientNo;
UPDATE PURCHASE
SET Amount = Amount * (1 - dr), DiscountRate = dr;
END;
/
I am unsure if you want to constantly be updating all your prior purchase records with new discount rates. If not, then I suggest this should Only be an insert trigger...but only you know your business logic to be implemented!

ORA-02019:connection description for remote database not found - left join in a view

I have 3 tables:
table1: id, person_code
table2: id, address, person_code_foreing(same with that one from table 1), admission_date_1
table3: id, id_table2, admission_date_2, something
(the tables are fictive)
I'm trying to make a view who takes infos from this 3 tables using left join, i'm doing like this because in the first table i have some record who don't have the person_code in the others tables but I want also this info to be returned by the view:
CREATE OR REPLACE VIEW schema.my_view
SELECT t1.name, t2.adress, t3.something
from schema.table1#ambient1 t1
left join schema.table2#ambient1 t2
on t1.person_code = t2.person_code_foreing
left join schema.table3#ambient1 t3
on t3.id_table2 = t2.id
and t1.admission_date_1=t2.admission_date_2;
This view needs to be created in another ambient (ambient2).
I tried using a subquery, there I need also a left join to use, and this thing is very confusing because I don't get it, the subquery and the left join are the big no-no?! Or just de left-join?!
Has this happened to anyone?
How did you risolved it?
Thanks a lot.
ORA-2019 indicates that your database link (#ambient1) does not exist, or is not visible to the current user. You can confirm by checking the ALL_DB_LINKS view, which should list all links to which the user has access:
select owner, db_link from all_db_links;
Also keep in mind that Oracle will perform the joins in the database making the call, not the remote database, so you will almost certainly have to pull the entire contents of all three tables over the network to be written into TEMP for the join and then thrown away, every time you run a query. You will also lose the benefit of any indexes on the data and most likely wind up with full table scans on the temp tables within your local database.
I don't know if this is an option for you, but from a performance perspective and given that it isn't joining with anything in the local database, it would make much more sense to create the view in the remote database and just query that through the database link. That way all of the joins are performed efficiently where the data lives, only the result set is pushed over the network, and your client database SQL becomes much simpler.
I managed to make it work, but apparently ambient2 doesn't like my "left-join", and i used only a subquery and the operator (+), this is how it worked:
CREATE OR REPLACE VIEW schema.my_view
SELECT t1.name, all.adress, all.something
from schema.table1#ambient1 t1,(select * from
schema.table3#ambient1 t3, schema.table2#ambient1 t2
where t3.id_table2 = t2.id(+)
and (t1.admission_date_1=t2.admission_date_2 or t1.admission_date is null))
all
where t1.person_code = t2.person_code_foreing(+);
I tried to test if a query in ambient2 using a right-join works (with 2 tables created there) and it does. I thought there is a problem with that ambient..
For me, there is no sense why in my case this kind of join retrieves that error.
The versions are different?! I don't know, and I don't find any official documentation about that.
Maybe some of you guys have any clue..
There is a mistery for me :))
Thanks.

How to see Table detail when writing query?

How to see Table detail when writing query?
Hi, i am new to using Embarcadero DBArtisan for Oracle and Syabase queries executions.
but i am unable to see the tables and fields information when i write queries.
Forexample:
Databasname.User.Table.Fields
Suppose if i write first Database name and write .(dot) it should show me all users and when i pick one user and write .(dot) agian it should show me all tables inside and when i pick one table and write .(dot) it should show me all the fields inside.
But it is not doing that way. every time i have to describe table to find the specific field in the table.
I am woundering if i have to choose some option to see this information.
Thank you very much for your help.
Sybase, there is no User.
I think you have to write a cursor to loop over the DBs on a server.
For the rest of your question:
select db_name() 'databasename', b.name 'table', a.name 'fields'
from syscolumns a, sysobjects b
where a.id = b.id
-- and b.type = 'U' -- User tables only
It seems that there is a setting in Code Workbench. Please see page 733 in the DBArtisan User Guide.
From the Manual,
In the ISQL Window, when Enable Auto Replacement is selected on the Setting Tab,
the application uses "dot completion" auto population to display the list of columns
for the target table.

CodeIgniter Active Record select with 2 or more tables

I have this sql statement setup in my old code and want to move it over to active record, the problem that I'm phased with is how do I do a
SELECT news_items.id FROM
(SELECT news_items.* FROM news_items
JOIN feeds ON feeds.id=news_items.feed
LEFT JOIN news_item_country ON news_item_country.id=news_items.country
WHERE news_items.id=30758
ORDER BY date_item DESC )
AS news_items
GROUP BY news_items.id
ORDER BY date_item DESC
Trying to do this with Active Record, first I created the select that goes inside the select at least that is what I think needs to be done.
$news_items = $this->db->select('default_news_items.*')
->from('default_news_items ')
->join('default_feeds','default_feeds.id=default_news_items.feed')
->join('default_news_item_country','default_news_item_country.id=default_news_items.country','left')
->join('default_news_item_options','default_news_item_options.id=default_news_items.options','left')
->where($where)
->order_by('date_item DESC')
->limit($limit)
->get();
Next I create the actual select and reference the other select inside the from
if ($query = $this->db->select("
news_items.id,
->from($news_items)
->group_by('news_items.id')
->get()) {
It did not work, so I'm asking if someone have experiences with this and how to do it?
You can't do a subquery directly in native active record syntax. Check out this answer for a solution:
subquery in codeigniter active record
(The author wrote a library for active record subqueries http://labs.nticompassinc.com/CodeIgniter-Subqueries/ )
Without this or similar technique you need to keep your current select code at least for the subquery ($news_items).
Take a look at this answer of mine this might help how you can achieve it.
Using Mysql WHERE IN clause in codeigniter

Remove phone from Magento Admin > Customer > Manage Customer > Address

I want to remove the field PHONE and FAX from the Magento customer administration. I already removed all the fields and validations in the frontend, but this field is still in the backend
Thanks!
Try to delete them from DB.
Table eav_attribute.
Check entity_type_id firstly - it need to belong to customer_address;
SELECT entity_type_id FROM `eav_entity_type` WHERE entity_type_code = 'customer_address'
DELETE from eav_attribute where attribute_code IN ('telephone', 'fax') AND entity_type_id = ? (from previous query)
No code changes will be needed then.
Backup your DB firstly.
You should comment out the relevant lines of code in Adminhtml folder on approperiate place, suggesting you as for the front end , you already have done this, so let the exact path on you
rather then deleting from db, a better way would be commenting the relevant lines of code. as if something goes wrong, Mag will reload the db from the default script and the fields you deleted will appear again..
HTH...
Not much effort is required , just run these SQL commands
SELECT * FROM `eav_attribute`
Now look for Telephone under attribute_code, mostly its with attribute_id 31
Update the table using the following SQL statement
UPDATE `eav_attribute` SET `is_required` = '0' WHERE `eav_attribute`.`attribute_id` =31;

Resources