Questions tagged [singleton]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
18 views

Why use custom helper folder in magento?

i know so much about it It is a singleton It is use for injecting class and method. So please explain me more detail. Advance thank you for answer
Alok Tiwari's user avatar
0 votes
0 answers
44 views

when i open my website showing this error .Mage registry key "_singleton/log/visitor" already exists

I am a beginner in magento development . please help me
Aleena's user avatar
  • 1
1 vote
1 answer
16 views

Code optimization, adaptation to a large number of conditions

I need to make a condition, if the server code has a certain value, then it will set the appropriate currency. I did this via an if else condition. But if there are many 5+ conditions, it will look ...
Alice's user avatar
  • 148
0 votes
1 answer
396 views

Helpers are singleton classes?

Given this code <?php class Vendor_Module_Helper_Data extends Mage_Core_Helper_Abstract { protected $_currentCustomer = null; protected $_settingsHelper = null; public function ...
Raul Sanchez's user avatar
  • 3,217
1 vote
0 answers
374 views

Magento 1 EE 1.14.3.10 - Mage::getSingleton('core/resource')->getConnection('core_read') is returning null sometimes

We have Magento 1 EE 1.14.3.10. In the production, I tried to deploy some of the updates, took a code pull from GIT and cleared the cache. Since then it started throwing this error. No error if Amasty ...
Kalyan Chakravarthi V's user avatar
1 vote
1 answer
1k views

Error: Mage registry key "_singleton/mage_gextorshop/observer" already exists

(Sorry if my english is bad, but is not my language) My Magento version is 1.9.3.8 I tried to solved this error whit this in SSH: php -f shell/compiler.php disable php -f shell/compiler.php clear ...
Exe's user avatar
  • 145
1 vote
5 answers
2k views

When to use Mage::getSingleton() in my custom module/Ext

theoretically i know about Mage::getSingleton() & differences b/w Mage::getSingleton() and Mage::getModel() but my question is that in my custom module when to use Mage::getSingleton(){Normally ...
Wakar Ahamad's user avatar
0 votes
2 answers
349 views

500 PHP error on Mage:getSingleton('admin/session') after separating admin and frontend servers

Working with Magento CE v1.9.2.3 with Redis Doing development for a website that makes use of a separate frontend and admin server in their production environment. I'm attempting to deploy TaxJar and ...
sparecycle's user avatar
  • 1,459
1 vote
1 answer
3k views

magento 2 version of getSingleton

In Magento 2 we are using dependency injection in replace of old style getModel, getHelper etc I have a particular class that i find i am injecting in a lot of places which holds some general ...
Marty Wallace's user avatar
1 vote
3 answers
2k views

Convert getSingleton("core/resource")->getConnection($type) from Magento 1 to Magento 2

I need to convert some singleton method calls from Magento 1 to Magento 2. Specifically Mage::getSingleton('core/resource')->getConnection($type); How can I do this in M2? I know that I should ...
Vladimir Despotovic's user avatar
0 votes
1 answer
34 views

How to instantiate a custom session

I'm working on a module with a custom namespace session. I extended the Session class and created a new object, but every time I use the new object it overwrites the parent one while I need 2 ...
apedic's user avatar
  • 923
0 votes
2 answers
77 views

Magento 2 - how to get models, config(s), and order info similar to Magento 1 style (Mage::getBaseUrl, Mage::getModel, etc...)) [duplicate]

I am a complete Magento 2 noob. I know a lot of things changed, one of which is how to get the Singleton Mage:: instance and its methods. I know it is moved to vendor/ directory from Mage/Code/Core, ...
Vladimir Despotovic's user avatar
0 votes
1 answer
222 views

Difference between Mage::getSingleton('core/layout') and $this->getLayout()

I've been reading some tutorials and some use: $this->getLayout() To get the current layout, while others use: Mage::getSingleton('core/layout'); I was wondering if there's any difference ...
avlnx's user avatar
  • 103
4 votes
2 answers
4k views

What's the difference between getLastOrderId() and getLastRealOrderId()?

Does anyone have a quick and dirty explanation of the differences? Mage::getSingleton('checkout/session')->getLastOrderId() Mage::getSingleton('checkout/session')->getLastRealOrderId() I ...
thismethod's user avatar
0 votes
1 answer
889 views

Mage::getSingleton()

I am trying to learn Magento Admin Modue Development. In this regard I am following this tutorial. Here I got the below line. $statuses = Mage::getSingleton('web/status')->getOptionArray(); Now ...
abu abu's user avatar
  • 744
-1 votes
1 answer
7k views

What is the difference between Mage::getSingleton() and Mage::getModel() in Magento [duplicate]

Mage::getSingleton() always finds for an existing object if not then create that a new object but Mage::getModel() always creates a new object.
Singsys's user avatar
  • 39
1 vote
0 answers
93 views

How to instantiate my new class and methods

I'm looking to trigger anything on a /admin/customer/edit just to know it's working.. an echo or print.. I have this code below. app/code/community/YourModule/etc/config.xml <global> <...
thismethod's user avatar
0 votes
1 answer
67 views

Cannot access the Admin section to perform edits on webpage

Each time I try to access the Admin control panel of my site, I get an error message saying There has been an error processing your request Mage registry key "_singleton/...
Nat Kelli's user avatar
4 votes
2 answers
504 views

Helper's scope (when getting via Mage::helper())

I'm trying to understand couple of things about helper classes scope and lifetime. I think I got it but it's critical for me to be sure. So can you please tell me if I'm right about the following ...
Ronen Ness's user avatar
1 vote
0 answers
847 views

Mage registry key "_singleton/belvgall/observer" already exists [closed]

Mage registry key "_singleton/belvgall/observer" already exists Trace: #0 app\Mage.php(223): Mage::throwException('Mage registry k...') #1 app\Mage.php(477): Mage::register('_singleton/belv...', ...
Oscar ho's user avatar
0 votes
2 answers
158 views

Pass data from view to block

I'm trying to pass a message from view to layout by using a model. This does not work when using _redirect(); I know there is a magento core functionality, but I'd like to understand why my custom ...
xhallix's user avatar
  • 692
0 votes
1 answer
623 views

problem after install of an extension: Mage registry key "_singleton/aw_layerednavigation/observer" already exists [closed]

After intalling this extension, I can not acess to the front-end or admin.. I'm having this error: Mage registry key "_singleton/aw_layerednavigation/observer" already exists Trace: #0 /...
Api-dev Dont-add Rolando's user avatar
0 votes
2 answers
2k views

How is getContinueShoppingUrl() called by Mage::getSingleton('checkout/session')?

I'm using Magento 1.9 and am trying to gain a better understanding of the method, getContinueShoppingUrl(), when called by Mage::getSingleton('checkout/session') but can't seem to find the file that ...
Vee's user avatar
  • 219
1 vote
1 answer
1k views

Mage registry key "_singleton/ambase/feed" already exists

One of the extension from Amasty was already installed in my website. I've installed another extension OPC and now I'm getting the error Mage registry key "_singleton/ambase/feed" already exists. I'...
amitshree's user avatar
  • 6,896
1 vote
1 answer
364 views

_getsingleton/customer/session registry already exists [closed]

I have used this code in observer function and event i am using is "controller_front_init_before". Problem is due to first line. Please help me to resolve this issue $customer_session = Mage::...
Ankur Jain's user avatar
5 votes
2 answers
445 views

What is the life span of a helper in Magento 1?

As I understand, helpers are singletons in Magento. I was wondering what the life span of the singleton is in Magento. Is only 1 instantiated for the life of the app (web server process start to ...
Shilpam's user avatar
  • 249
14 votes
5 answers
16k views

Mage registry key "_singleton/weee/observer" already exists

When I try to add or edit a product I receive the following error: Mage registry key "_singleton/weee/observer" already exists Trace: #0 app/Mage.php(222): Mage::throwException('Mage registry k...') #...
littleredsunshine's user avatar
0 votes
1 answer
341 views

Accessing singleton model properties in another controller

I have a controller from which I am setting a property of my model $model = Mage::getSingleton('foo/bar'); $model->setData('name', 'somename'); echo $model->getData('name'); This outputs the ...
zamil's user avatar
  • 632
0 votes
1 answer
1k views

Getting New Session Id before session expires,checkout/session car is empty even cart has item

I have a local module, which adds product to cart.To add to cart i have some conditional check before adding to cart,and i am using getSingleton('checkout/session')->getQuote() object for getting ...
Manikandan Arunachalam's user avatar
19 votes
4 answers
17k views

Understanding Magento Registry

I have been wondering always, where is all the registry data stored in Magento ? I know that even singleton objects are stored in the registry. And registry is just a static array variable of the ...
Hashid's user avatar
  • 946
0 votes
2 answers
1k views

Can't share data across modules with Mage::getSingleton

I have used Mage::getSingleton to share data across and within Modules before, but I'm coming across a problem where its not working in this specific scenario. My module asks questions at checkout ...
andyjv's user avatar
  • 3,232
0 votes
3 answers
199 views

Query regarding the file Mage.php

I need to understand what the code below actually does? I found this in Mage.php public static function getSingleton($modelClass='', array $arguments=array()) { $registryKey = '_singleton/'.$...
Akash Goswami's user avatar