I need to make product urls like this "attribute1/attribute2/product-url-key" dynamically. I've found that the urls of every product are in the enterprise_url_rewrite table, request path field.
I would like to make change to the indexer process as well, so the changes will stay when its rerun, but I don't know where it is?
Good afternoon! Let's break this down:
I need to make product urls like this "attribute1/attribute2/product-url-key" dynamically
Yes - you can create URL rewrites dynamically using the Magento models that represent the database table you've identified already:
/** #var Enterprise_UrlRewrite_Model_Redirect $rewrite */
$rewrite = Mage::getSingleton('enterprise_urlrewrite/redirect');
// Create new record or load the existing one
$rewrite->loadByRequestPath($requestUrl, $store->getId());
$rewrite
->setStoreId($store->getId()) // define which store the rewrite should be
->setOptions(null) // specify any rewrite/redirect/custom options
->setRequestPath($requestUrl) // specify the request URL
->setIdentifier($requestUrl)
->setTargetPath($targetPath) // specify the redirect target
->setEntityType(Mage_Core_Model_Url_Rewrite::TYPE_CUSTOM)
->setDescription('Add a comment if you want to');
$rewrite->save();
This will attempt to load an existing URL rewrite/redirect by the $requestUrl and will return an empty model if it was not found which you can embellish with your data and save.
The "options" define whether it's a temporary or permanent redirect (302 vs 301).
More information here via the Magento EE user guide.
I would like to make change to the indexer process as well, so the changes will stay when its rerun, but I don't know where it is?
Don't worry about it. The (modern) Magento database has table triggers wherever records need to be indexed, and will detect creations, updated and deletions on those tables. The indexers will detect that change need to be made and will make them for you as required.
If you're seeing URL rewrites disappearing it's most likely because you've been adding them directly to the index table with SQL, so the table is rewritten whenever the indexer runs. To avoid this use the model as noted above and everything will be saved into the correct location and indexed properly.
Related
Is there a setting to allow multiple nodes with the same URL?
We've setup a small CMS type system where web content admins can add new pages with content and widgets to the website.
They sometimes make the mistake of adding the same name to multiple pages under the same parent causing 2 nodes to have the same URL. I would rather not showing and ignoring the duplicate than throwing an exception.
The URL (when supplied) is used as a key of a dictionary. By definition, the key of a dictionary must be unique. Even if the duplicate URL check were removed, the dictionary would throw a more cryptic duplicate key exception.
I would suggest sanitizing the data before reading it with IDynamicNodeProvider or ISiteMapNodeProvider.
Options
Add a check to the data entry form to ensure the URL is unique before allowing it to be saved.
Put a unique constraint on the URL field in your database to throw an exception upon data entry instead of when it is read.
Put a distinct filter in your query so only one of the duplicate URL records is considered when adding them to the SiteMap.
Consider using controller, action, and id (from the primary key) when using data-driven URLs. The only thing that really needs to be data-driven are the Routes, and the URLs will be resolved correctly within MvcSiteMapProvider.
I am writing an extension in Magento that will import files. I want to keep a list of these files in the database somewhere so that I know not to process them again.
Is there any built in functionality that I can hijack to keep a list?
If not, how would I go about creating a new table to hold these values?
I was thinking of simply using Mage_Core_Model_Config and storing the values in there, however it probably isn't the best idea.
you can create a datatable that stores them. additionnaly, you will need to create the according model and define them in a config.xml under a ressource tag.
if you just need to store a value, you can do it in the core_config_data.
first of all, sorry for my english, but I'll try to explain myself best I can.
My question is little tricky, because I made some important changes in the core code of VirtueMart.
For some reasons, I added an attribute to the Custom Fields, like Price, called Availability.
TIP: The admin site is in Spanish. Disponibilidad = Availability
So, now, when I try to change any value of any created Custom Field, I can't save it. I mean, I can change the value, but when I apply them, It doesn't be saved.
The only field that I can change, is the field I created, the Availability (ironically).
So, my principal question is, how does VirtueMart to pick up the data from the table and sends them to the database?
I work with
Joomla v.2.5.11
VirtueMart 2
Thanks
The workflow is like follows,
When you save the products details on the backend , It calls a function store() on the product.php model. under administrator/components/com_virtuemart/models/. Inside this function an area like follows.
if(!class_exists('VirtueMartModelCustom')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'custom.php');
VirtueMartModelCustom::saveModelCustomfields('product',$data,$product_data->virtuemart_product_id);
It loading the custom model file from the same path and do the task inside saveModelCustomfields()
Hope it helps..
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!
My magento website has 5 store views. When we are in a product in English and select French, it redirects correctly and show the product in French. But when it comes to categories, it doesn't work at all.
I'm on a category with the url http://myweb.com/en/body-care, if I change to the Spanish view, it doesn't redirect to the url "../cuidado-del-cuerpo" it just goes to to http://myweb.com/es/body-care and shows a 404 error (it changes the 'en' for 'es', but doesn't change the last part of the url).
The rewrite is not defined on the URL Rewrite Management section. I have 5 categories and 5 store views, so it's not a good idea to create the rewrites rules manually.
How can I solve this? Why the rewrite rules were not written when we created/modified the url of each category?
1) Can you check if the urlkey is definable on store view level, or if it is set to website level? That way, you can only create 1 url key for EN and ES. You need it to be at store view level, do define 2 separate values.
2) Is there something in your error log? (and is your error log turned on?) Normally url rewrites are created automatically for each store view. If not, you may need to manually reindex.
It's hard to give further advice, since the problem could be anywhere (conflicting module? bad code?)