Magento enterprise CMS request_url not updating - magento

Using Magento 1.14.2
I am not sure if anyone had this issue before but when I update a URL key in Magento Enterprise CMS the changes are not taking effect in the tree.
Example: When test page's URL key is updated from test to test-1, I can still access http://test.com/someparent/test.html. Tried loading http://test.com/someparent/test-1.html and it comes up as 404 page not found.
My investigation so far:
When URL key is updated identifier field in cms_page is updated but not in enterprise_cms_hierachy_node (request_url key).
Went a bit further to look at the code and found that in app/core/Enterprise/Cms/Model/Hierarchy/Node appendPageToNodes()
if ($node->getPageExists()) {
continue;
} else {
$node->addData($pageData)
->setParentNodeId($node->getId())
->unsetData($this->getIdFieldName())
->setLevel($node->getLevel() + 1)
->setSortOrder($sortOrder)
->setRequestUrl($node->getRequestUrl() . '/' . $page->getIdentifier())
->setXpath($node->getXpath() . '/')
->save();
}
So, if page node exists it does nothing and moves on. Where as if doesnt exist it inserts new record.
Just wanted to know if any others have experienced this issue and what did you do to resolve the issue?

Follow the steps below, You will knock it off.
Take a backup of your database in .sql file using mysqldump command
Truncate the table core_url_rewrite in your database
Now refresh the magento home page.
Check weather the rows added to core_url_rewrite table.
You are done!.

Related

Products are not displaying in Frontend after import in Magento

I have imported products using System - Import/Export - Import option.
I can see my products in Admin panel, but not in Frontend.
I tried Re-indexing, cache clear, cache refresh, physical cache remove.
also checked product stock status, availability etc. Everything is ok.
But they are not displaying in frontend. I marked onething, If I open product that I imported using csv, just saved without any change, it starts displaying. But I have 100s of products. So I can't use this solution.
So please help me where I am going wrong in csv. below is my csv screenshot.
You need to ensure that the products are attached to a website.
This can be done via a bulk update:
Access the product listm select all
Alter attribute
Products information -> websites
It can also be done in the csv by using a "_product_websites" field and setting it to the website name or 'base'.
I forgot which CSV columns are mandatory but I do remember that if some are missing the importer does not tell you that but instead you get the behaviour that you are describing.
The simplest way to find out what is mandatory is to:
Fix bugs in Magento ImportExport module
Create a new product in admin
Check that the new product is visible on front-end
Export the new product with Magento ImportExport exporter
Delete created product
Import the previously exported product csv
Clear cache and reindex data
Check that product is visible on front-end (it should be)
Compare your CSV with the exported one and try to figure out what is missing from it
Try to import your CSV with added/fixed columns and add data untill the product is imported so that it is visible on front-end
This requires allot of trial and error...
The missing columns in my case had always the same value so if this will be the case with your problem as well you can simply extend CSV importer and hard code those values in there instead of fixing your CSV manually.
Since your product gets saved correctly if you open it in admin and save it you can also:
Import a product
Export that product
Open that product in admin and save it
Export newly saved product
Compare exported CSV-s where they differ
Fixing Magento ImportExport bugs:
First bug is that if you import multiple products the quantity informatino from the first product is used for all the products. To fix this you have to add $row = array(); right before $row['product_id'] = $this->_newSku[$rowData[self::COL_SKU]]['entity_id']; in Mage_ImportExport_Model_Import_Entity_Product::_saveStockItem() function.
The second bug causes Magento ImportExport module to return a foreign key constraint error when importing multiple products. Error happens because magento splits products data into multiple segments and if one product is located in two segments importer will delete data that was imported for the product in first segment before importing the second segment thereby causing database corruption (see this link for detailed explanation - this is where I got the solution below).
Note that removing foreign key constraint will not fix the problem but will instead make it worse since the database will contain corrupt data.
To fix it you have to change the code in Mage_ImportExport_Model_Import_Entity_Abstract::_saveValidatedBunches() function:
After if ($startNewBunch || !$source->valid()) { add
if ($startNewBunch && count($bunchRows) > 1) {
$arrKeys = array_keys($bunchRows);
$arrNew = array();
while(($tRow = array_pop($bunchRows))) {
$tKey = array_pop($arrKeys);
$arrNew[$tKey] = $tRow;
if ($tRow['sku']) {
break;
}
}
$nextRowBackup = array_reverse($arrNew, TRUE) + $nextRowBackup;
}
Hope this helps.
I had the same problem recently and I spent some time tring to figure it out...
Looks like magento needs a status flag for every product otherwise magento will not show it in the dashboard.
Solution : add a "status" column to your CSV file and set all the statuses to "Enabled"
(yes it's not a boolean. Just use the string inside the quotes as it is :)
I was stuck with the same problem, i then visited my var/export/export_all_products file, downloaded it again and uploaded the same back through import, logged out of my account and logged-in back, all products were back. This worked as a backup for me and i could see all the products back at the back-end.
Import as you have. If they are enabled, but not showing...
then you can fix this by clicking "select all" products in the "manage products" table and then "change status" and then select "enabled." This process might take a minute.
Visit your store and you should see your frontend with products.
Some kind of bug with the status/enabled setting.
You must have next fields in CSV
sku
_attribute_set
_type
_category
description
image
name
price
short_description
status
tax_class_id
thumbnail
visibility
weight
qty
_product_websites
is_in_stock
Please note that field is_in_stock is mandatory even if qty more then 1
In magento 2 we need to reindex in index management to display the products in frontend.
We can reindex through cmd.like the given example we need to enter magento file directory after that cmd php -f bin/magento indexer:reindex to reindex .
When I first started importing products via csv although I set the product to enabled, I figured out that even though it shows in the magento back end as enabled, it actually isnt - think its to do with setting the field contents as "1" or "0" rather than "enabled" or "disabled/null".
To get around this, after a import I simply selected all the products in the back end and change status to enabled - it fixes issue.
But, I do think if I simply changed the data in the csv import it would save me this minor in-convenience.

Fatal error: Call to a member function setFinalPrice() on a non-object?

When i installed an extension named ajax pro on magento 1.702. when i add a product to cart,it shows
Fatal error: Call to a member function setFinalPrice() on a non-object in ..app\code\core\Mage\Sales\Model\Quote\Item\Abstract.php on line 73.
although i delete all this extension's files and folders. when i add a product to cart. the error still exist? how to correct it. thank you. i have clear all the cache.
I got this error after programmatically creating a quote with a different store id to the default store id.
Fix was to run this sql (after backing up all sales_flat_quote tables, of course):
DELETE FROM sales_flat_quote_item;
Note that TRUNCATE sales_flat_quote_item won't work due to referential integrity, and that the above command will remove the linked records from some of the other sales_flat_quote tables as well.
In reply to the comment - if you don't have access to the database then ask your hosting provider to give it to you (most give you some sort of access - eg phpmyadmin) you can run it as a code snippet, I guess:
<?php
// Save this in Magento root directory.
require_once( dirname(__FILE__) . ' /app/Mage.php');
umask(0);
Mage::app()->setCurrentStore(0);
$resource = Mage::getSingleton('core/resource');
$dbw = $resource->getConnection('core_write');
$query = "DELETE FROM sales_flat_quote_item;";
$dbw->query($query);
It's not a good idea to run that on a live production system - existing customers will lose all the items in their carts - though if your site is broken and you've nothing left to lose, maybe give it a go!
To backup the database without access to it, https://www.phpmyadmin.net/ or a similar tool will help there. You can also run the above query directly using that.
Delete session files from var/session thats it.
If it is throwing for all the customers then you can delete sales_flat_quote_item table. If this happens only for particular customer then do the following thing. In this case, all the quotes wont be deleted.
Get the customer id from sales_flat_quote_address(column name: customer_id) table. Here you can get the specific quote id(column name in table is quote_id) which is causing the problem.
Example: SELECT quote_id FROM sales_flat_quote_address where customer_id=23423
Now, go to sales_flat_quote_item then delete the particular records which is causing the problem.
Example: DELETE FROM sales_flat_quote_item WHERE quote_id=43535

why magento using other product's url key for url rewrite

I am using magento 1.7. i am faceing strange problem. magento making duplicate product url with random number with wrong url key please my attached screenshot
I also empty table rewrite_urls and reindex urls but still i am getting wrong urls. please help me to solve this problem. if you are unable to view images in question then please click on links duplicate product urls and Product in admin panel
,
Let me make understand u with example
Like i have one product named "example" and url key is "example" Url will be
www.example.com/example
and now i have created new product "xyz and url key is "xyz" and url should be
www.example.com/xyz
but magento generating url
www.example.com/example-123
This seems to be a bug in 1.7.
If you have multiple simple products with the same url key as the configurable product (e.g. all names are the same), than magento always creates a new url rewrite on every index process.
Example:
First index:
myproducturl (config product)
myproducturl-id (simple product with its id appended, so far so good)
Second index:
myproducturl (config product)
myproducturl-randomnumber (simple product with random number, BAD)
myproducturl-id --> myproducturl-randomnumber (rewrite to the new url)
And on every new index process the last step will be repeated, so always a new random url key is generated.
If magento would check, that a url key with the id for that product already exists, this should be no problem.
After a few months, you will have a really big url_rewrite table, because nothing will be deleted and on every run, at least 1 record for every product with the same url key will be created.
I was able to eliminate the extra numbers at the end of the URLs by truncating the table "core_url_rewrites" (I made sure to make copy first) then reindexed it.

Magento creating invoice redirect to wrong url

When I create an invoice from the order in the backend, this on this url:
http://www.site.com/index.php/safe/sales_order_invoice/new/order_id/4372/
But when the Invoice is about to be created it goes to:
http://www.site.com/shop/safe/sales_order/view/order_id/4372/
You see the (Shop), which is mostly correct because the storefront is named that(We had 2 storefronts once) If I remove the (Shop) part from the url, I'm getting back to the correct page and it shows that the invoice was correctly created. This only happens from the Order itself. If I use Mass action to create invoices from the orders list, it's not giving me any problems.
If anyone else has the problem (Using multi stores)
Please check your database, core_config_data and see if web/secure/base_url etc. is redirecting to the right path. And make sure to check that it's doing so for the right store ID that is giving you the trouble.
My problem was that the secure path for one of my stores, was ruining it.
All works fine now!

"There was a problem with reindexing process." after product import

Using Magento 1.6
I had to make some bulk changes to my catlog and so did a full product export, made the changes then imported the ammended file.
Afterwards there were a few index that needed updating, all of them except the "Product Attributes" index correctly.
When I try to re index that one I get the error "There was a problem with reindexing process."
There are no new errors created in var/report and so I have no idea what the problem is.
csv -> http://lazytrek.com/magento_export.csv
edit - As per OSdave's suggestion I got the following error:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '84-142-1-58' for key 'PRIMARY'
After struggling for hours I finally found a solution. In fact, It's a very simple solution:
Backup your database
Open phpMyAdmin and truncate (empty) the table catalog_product_flat_1
That's it. After that I was able to index all data and, until now, everything else works perfectly. This worked for me. I hope it works for you too.
PS: using Magento 1.6.0.0
OK I fixed this myself
In the SQL error the first number (in my case 84) indicates the product id, something did not import properly with that ID, I went into the product, saved it manually and hey presto I could re-index.
Hope that helps someone :-)
Remove the lock files in var/locks and try again.
I'd advise you reindex in SSH if you have a large data set
php shell/indexer.php -reindexall
Source :: https://magento.stackexchange.com/questions/24729/there-was-a-problem-with-reindexing-process
I also had this issue and was getting the following in my exception log:
Integrity constraint violation: 1062 Duplicate entry '706-168-2-60' for key 'PRIMARY''
Eventually I discovered (as posted above) that this was a problem with product ID 706 (the first digits before '-' are the product ID.
Simply opening this product within the Magento admin and saving it fixed the issue with this product, however, in my case I also had a problem with product 707, 708, 709, etc, etc...
What I then discovered is the second set of digits identify the attribute ID. I figured out which attribute this was by opening any attribute and replacing it's ID in the URL with the one in the exception log.
I then searched for a series of products (in my case 700 to 800), selected them all and used "Actions" "Update attributes" in the top right of the Catalog - Manage Products page.
I amended this attribute for all of them (which was fine for me) and the indexer worked.
If you can't set this attribute to be the same for all your products I'd suggest a bulk import to reset just this.
Last night, I was having the same problem. After following the steps outlined by OSdave to get the more precise error message, I saw my error was the same as yours.
But it wasn't just with 1 product there were several hundred products causing errors (each one saved brought up a new one). And it wasn't all with the same attribute (I'd updated multiple attributes across a database of over 4,000 products in my last import).
Since everything seemed to actually be in the database correctly (since re-saving seemed to be fixing it and giving the proper data to the final saved product), I had an idea.
Why not export all 4k products, and then re-import the same file without modification and see if that clears it.
It worked!
tl;dr: If you're having this problem with multiple products needing to be re-saved, export your whole inventory (or the relevant section if you can segment in a useful way), and re-import the same file with no modifications.
I'm using Magento v 1.9.0.1
Thanks OSdave,
It's same error for me, I changed this
in Mage_Index_Adminhtml_ProcessController edit line 138, from Mage::helper('index')->__('Cannot initialize the indexer process.') to $e->getMessage():
then tried re-index, it's shows the below error
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '8308-2018-1-2788' for key 'PRIMARY', query was: INSERT INTO catalog_product_index_eav_idx (entity_id,attribute_id,store_id,value
then, I remove the product with ID '8308' and recreated and after tried to re-index, it working fine.
But don't the exact root cause of issue. I hope it's help to someone!
Double check the catalog_product_entity,catalog_product_entity_datetime,catalog_product_decimal,catalog_product_int, catalog_product_text,catalog_product_varchar table columns have with respective UNIQUE KEY's.

Resources