Hot answers tagged

12

Based on the duplicate question, I'm just going to explain how to do it in an helper/controller First you have to inject the Magento\Store\Model\StoreManagerInterface in your constructor: protected $_storeManager; public function __construct( ... \Magento\Store\Model\StoreManagerInterface $storeManager ) { $this->_storeManager = $...


8

The problem is that both the admin router and the frontend routers have the same node. Even if they have different frontNames. If you update your admin xml to the following: <admin> <routers> <testimonial_admin> <use>admin</use> <args> <module>...


7

You should use var url = "<?php echo $this->getUrl('customtabs/ajax/deletelens/');?>"; Note the removal of the first /.


6

The cleanest way to do that is: echo $this->getUrl('*/*/*', array('_use_rewrite' => true, '_forced_secure' => true)); The first parameter '*/*/*' means that you stay on the same module/controller/action The second parameter is an array of options The option '_use_rewrite' let you keep the rewrited url, for example: /my-category/my-product-url-...


6

You cannot rewrite abstract classes What you need to do is rewrite the class that extends, and inherits the abstract class methods. As an example: Mage_Catalog_Block_Product_View extends Mage_Catalog_Block_Product_Abstract, so if you want to change the behaviour of getAddToCartUrl when you view a product, you'd rewrite Mage_Catalog_Block_Product_View Can ...


6

First I want to say that you have a lot of question about how Magento works. I like the spirit. The method helper() that you call from inside a block, that is the same as calling Mage::helper() is a factory. It returns you the instance of a class. A helper in this case. The method Mage::helper looks like this: public static function helper($name) { ...


4

There is no page to display the agreements. They appear in the checkout. But you can create one. Create a static page with this content. {{block type="core/template" template="agreements/list.phtml"}} Then create the template file agreements/list.phtml in your theme with this content: <?php $agreements = Mage::getModel('checkout/agreement')->...


4

I'm pretty _secure only works if the URL natively supports HTTPS. In case it does not (which seems to be your case as your code is totally valid) you can force it using _forced_secure: $this->storeManager->getStore()->getUrl('someurl', ['_secure' => true, '_forced_secure' => true]); Also you were casting true to a string 'true' I'm not sure ...


4

if you have created your block class by extending \Magento\Framework\View\Element\Template In Your phtml file use following code : $block->getUrl("zipcode/index/index"); To get the url. if you need the url in the block class itself use : $this->getUrl("zipcode/index/index"); Comment if you need more help.


3

That's because the full URL is not stored in the database, but generated from base URL and path, and Magento is smart enough to only calculate derived attributes once per model, then cache them internally. Unfortunately you are using the same model instance $subcat for each category and just reload different data, so you get the first cached value every time....


3

I think Mage::getUrl() might rely on you having an admin session (probably for the url keys), but if you just need a link to view the order, you can generate it yourself - it'll be something like: https://<domain>/index.php/admin/admin/sales_order/view/order_id/<orderid> The order id, of course, being found in $order->getId() - not the ...


3

generate it like this: $url = Mage::helper("adminhtml")->getUrl('admintml/your_module/index'); So you should place your controller in Petra/DailyOrders/controllers/Adminhtml/ControllerName.php and call it like this $url = Mage::helper("adminhtml")->getUrl('admintml/controllername/index');


3

inject storeManagerInterface in constructor public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, ..... ) { ... $this->_storeManager=$storeManager; } Now you can GetUrl by command $this->_storeManager->getStore()->getUrl('routepath', ['_current' => true]);


3

Within templates $this->helper() gets translated to Mage::helper() So this code means this is a call to Mage::helper('customer'), which gets translated to Mage_Customer_Helper_Data (or any class that rewrites it) in the backend. If you're curious how this is done have a look at Mage_Core_Model_Config::getHelperClassName()


3

This is the alias for the Helper class used, this alias is used to build the class that is loaded to run the function specified. In this case the helper alias for customer maps to Mage_Customer_Helper. Since only the class alias is specified the function getHelperClassName will append /data to load the default Helper class with the name: ...


3

I managed to get url with this method: \Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action\UrlBuilder $actionUrlBuilder $this->actionUrlBuilder->getUrl('route_path', $storeId, $code);


3

Magento add URL-rewrite for product here: Magento\CatalogUrlRewrite\Observer\ProductProcessUrlRewriteSavingObserver In your extension you should add "before" plugin for execute method. See magento tutorial In your plugin method you should add: $product->setUrlKey($product->getUrlKey() . '_' . $product->getId()); (Of course, also you can add some ...


2

Solved and Tested: You can't extend Mage abstract class in your custom module directly but you need to find such mage class which extends your desire mage abstract class, so you extend that class. Example: - Mage_sales_order_pdf_abstract (you want to extends this class) Mage_sales_order_pdf_invoice extends Mage_sales_order_pdf_abstract What you need to do ...


2

General warning — while ideally it should be supported, what you're trying to do isn't really meant to be done by a non-core Magento developer. The abstractions around routing are confusing, and possibly incomplete. It's relatively safe to introduce a new router object with a match method, but (as you've seen) expecting it to behave in predicable ways with ...


2

What you mentioned already, is correct. The Global scope is the same as the Admin scope. They are not quite the same, but because all other scopes (Store View, Store, Website) are managed from within the Magento Admin Panel, the Magento Admin Panel needs to have the scope Global to work. This also means that the Base URL of your Global Scope needs to point ...


2

You can get controller url by $this->getUrl('YourModulefontName/ajax/deletelens');


2

Surely you could return urldecode($this->getUrl('*/*/*', array( '_current' => true, '_escape' => true, '_query' => array( 'filtering' => array_unique($filtering) ) ))); Or am I missing something?


2

Got this work to set store id in product collection's product object Just need to add this like foreach ($collection as $product) { $product->setStoreId($storeId); } so in mode/product/url.php this will get true $rewrite = $this->getUrlRewrite(); $rewrite->setStoreId($product->getStoreId()) ->loadByIdPath($...


2

It's much more simple. You can simply get the original path info. Mage::app()->getRequest()->getOriginalPathInfo();


2

This should get you what you need: Mage::getUrl('');


2

The url should contain /active_tab/order_creditmemos/ where 'order_creditmemos' is the name attribute of the tab <a href="#sales_order_view_tabs_order_creditmemos_content" ... name="order_creditmemos" ...> See /app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/View.php /** * Retrieve back url * * @return string */ public function ...


2

Define constructor of your class here I am creating a class in model path: PackageName/ModuleName/Model/Test.php and add the following code public function __construct( \Ipragmatech\Customurls\Helper\Data $helper, \Magento\Store\Model\StoreManagerInterface $storeManager ){ $this->_helper = $helper; $this->_storeManager = $storeManager;...


2

If you want to allow access to contact us page just add contacts_index_index in $allow array and undo the condition for $contactPaths if you want to add any other url in the array you can get the Full action name by calling this code on that page echo Mage::app()->getFrontController()->getAction()->getFullActionName()


2

You can use product sku value in product "URL Key" field. Or You can use an extension for custom product URL. Its free and easy to use. https://www.magentocommerce.com/magento-connect/catalog/product/view/id/30396/s/custom-product-urls-seo/


2

From getUrl Magento call a particular action of a module's controller. the syntax in function is like getUrl('modulename/controller/action') for example if you use getUrl('customer/account/create') then it will call Customer module's AccountController.php file and in this file it call createAction function. To locate file you have to go to app/code/...


Only top voted, non community-wiki answers of a minimum length are eligible