Questions tagged [object]
The object tag has no usage guidance.
66
questions
1
vote
1
answer
54
views
Magento 2: Custom module admin configuration access errror
I have used a custom module and when click on the admin configuration module menu throws the error.
This error is facing only in production mode. And faced issue when run php bin/magento setup:di:...
0
votes
0
answers
53
views
How to solve Type Error occurred when creating object: Webkul\MpBlog\Block\Account\Navigation?
1 exception(s):
Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Webkul\MpBlog\Block\Account\Navigation
Exception #0 (Magento\Framework\Exception\...
0
votes
1
answer
25
views
How do I know what data I can access via an observer?
I'm trying to use the sales_order_invoice_pay observer.
I can see the dispatch in:
/vendor/magento/module-sales/Model/Order/Invoice.php
$this->_eventManager->dispatch('sales_order_invoice_pay', [...
0
votes
1
answer
83
views
Magento 2 - How to find out which data is available for an object?
I have a quote item:
/**
* @var \Magento\Quote\Model\QuoteFactory
*/
protected $_cartFactory;
public function __construct(
...
\Magento\Checkout\Model\CartFactory $cartFactory,
...
) {
...
0
votes
2
answers
72
views
Issue in extending a model magento 2
I want to extend the Magento\ConfigurableProduct\Helper\Product\Options\Loader as per this github issue https://github.com/magento/magento2/issues/21663#issuecomment-477966963
My di.xml file is
<?...
0
votes
1
answer
158
views
Magento 2.3 How to convert JSON response array to array of same type object REST API
I have created a custom api to get review and rating summary:
public function getRatingSummary($productId)
{
$result =[];
$product = $this->_productRepository->getById($productId)...
0
votes
1
answer
515
views
Magento 2: How to pass object as a argument from phtml
I want to pass object as a argument from phtml file how can I do this? As I've checked we can pass string using $block->setData('var','test') but didn't found for object.
4
votes
1
answer
488
views
Magento 2 What is Alternative of Zend\Form\Annotation\Object in php 7.2
i was using PHP 7.0 i used to use Zend\Form\Annotation\Object Now i have upgraded my system to 7.2 and Now i am getting an error that
PHP Fatal error: Cannot use Zend\Form\Annotation\Object as ...
0
votes
1
answer
365
views
Error occurred when creating object
I have a plugin with constructor
<?php
namespace Vendor\Contact\Plugin\Controller\Index;
use \Zend_Validate;
use Magento\Contact\Controller\Index\Post;
use Magento\Framework\App\Request\Http;
use ...
2
votes
1
answer
204
views
Magento 2: Regarding Initialling Interface
As per object oriented programming concept, an interface can not be initialised directly but can be used to implement in other class and the instance of that class can be created. So my question is ...
0
votes
1
answer
333
views
How to create empty object of Payment class in Magento 2
I have to create Payment object in
vendor/magento/module-paypal/Plugin/OrderCanInvoice.php
Is it $foo = new Payment() ?
It gives me an error
Uncaught ArgumentCountError: Too few arguments to ...
0
votes
0
answers
104
views
Convert Object to Array
I try to convert my custom Object to Array.
Here my Object :
Namespace\Project\Model\Custom\Object Object
(
[attr1:protected] => value1
[attr2:protected] => value2
[attr3:protected]...
0
votes
1
answer
217
views
How to move first element of object to first Magento 2
My object is something like this
object(Magento\Framework\Data\Collection)[8565]
protected '_items' =>
array (size=3)
15841610 =>
object(Magento\Framework\DataObject)[8701]
...
0
votes
1
answer
571
views
Magento2: How can I access Zend\Stdlib\Parameters Object array?
I have below result:
echo "<pre>";
print_r($data); die();
Result
Zend\Stdlib\Parameters Object
(
[storage:ArrayObject:private] => Array
(
[success_url] =>
...
0
votes
1
answer
38
views
How to see inside $this object in Magento 2 logger
How can I see inside the $this object in my logger file using prs logger?
I tried this
\Magento\Framework\App\ObjectManager::getInstance()->get(\Psr\Log\LoggerInterface::class)->info("in ...
0
votes
2
answers
360
views
How can we check context object list for observer in magento2
I want to know context object list which we can use methods directly from $context object in Observer.
Just like in below URl.
Magento2 – Use Defined Methods from Context Object
URL:- https://webkul....
2
votes
3
answers
5k
views
How to delete object from collection in magento2
How to remove any object from magento 2 collection.
If we have collection of products and we want to delete product which is at first index . how to delete that product without deleting it from ...
1
vote
3
answers
2k
views
How to convert this object data into array?
I have this Data Object value.
Magento\Customer\Model\Data\AttributeMetadata Object
(
[_data:protected] => Array
(
[frontend_input] => boolean
[input_filter] ...
2
votes
3
answers
371
views
Difference between load() and get() methods
While going through the Magento code I have been seeing a lot of instances of:
$objectName->load($foo)
or
$objectName->get($foo)
and I was wondering, what is the difference between the 'load'...
0
votes
2
answers
208
views
How to replace direct use of Object Manager?
in the success.phtml file I currently have a direct use of the object manager, which I am now reading is not best practice. I was wondering how to make a constructor to replace the following code in ...
5
votes
0
answers
217
views
HELP - How to convert Default SOAP-v2 API Magento Objects into XML Values?
In Magento1.9 - product collection by default return values as Magento Objects using soap v2, how can i change into XML,
<?php
ini_set('display_errors','On');
$proxy = new SoapClient('abc.com/api/...
1
vote
1
answer
1k
views
Magento 1 - Convert Object into an array value
I was trying to get the information of tracking in the UPS. I got on of the method from the core (app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php => method name getTracking($trackings)) that ...
2
votes
0
answers
480
views
Magento2 - How to return string as object in webapi response?
Can anyone let me know how to return success message with object like this same as magento does for the exception in REST webapi:
{
"message": "A customer with the same email already exists in an ...
0
votes
0
answers
829
views
Magento 2 - Update product collection price and reset collection
I want to update product price from the collection and use that collection again. I have written a code for that as per below:
$price = 23;
foreach ($this->_collection as $key => $value) {
...
1
vote
0
answers
35
views
Magento magento_default_pages_tmp objectID(10) too big?
I'm trying to use Algolia in Magento for autocomplete search. It tell me that this object is too big.. Now I'm not interested to algolia working or not. My interest is to understand what is this ...
3
votes
1
answer
182
views
Script error while uploading category image in Magento 2.1.9 using IE11
I have a Magento 2.1.9 installed. When I try to upload an image for a category from backend in the IE11 browser it shows a script error
SCRIPT438: Object doesn't support property or method 'set'
...
6
votes
2
answers
2k
views
Magento 2, How to get Payment infoInterface from order?
I am working on a custom payment method.
I am stuck in between where one of my methods required Payment object of \Magento\Payment\Model\InfoInterface
But I am getting Magento\Sales\Model\Order\...
13
votes
1
answer
4k
views
Magento2 plugin around method different between callable and Closure paramters on param $proceed
I have checked magento2 ,There are two types of parameters that can be sent to
around method
\Closure $proceed example aroundSave(\Magento\Catalog\Model\Product $subject, \closure $proceed)
callable ...
1
vote
0
answers
21
views
Class instatiation with data
I have created custom Factory class for my custom model class. Of course basically you can instantiate it by calling $this->objectManager->create(Someobject::class);. But, ObjectManage has also ...
1
vote
0
answers
82
views
Can't able to set value for nested object param
Below one is my custom observer object, I need to get/set value of processor
object {
["_quality":protected]=> int(10) /* 1st quality param.*/
["_processor":protected]=>
object(...
0
votes
2
answers
1k
views
Get all gallery images
I'm trying to pull through the gallery images on the product page because customizing the gallery with code:
<?php $_product = $block->getProduct(); ?>
<?php $gallery = $_product->...
1
vote
1
answer
1k
views
Magento 1.9 - Order object passed to event observer is empty
I am trying to get data from a new order placed on our website to use it for integration with our ERP/CRM system.
I use the event sales_order_place_after and my observer function fires as expected, ...
9
votes
2
answers
17k
views
Magento2: How to convert JSON to Array of nested objects
I am wanting to understand if there are some functions in Magento Framework which will assist me in mapping an array of nested objects from JSON (such as what would happen when the REST API is ...
1
vote
1
answer
37
views
Magento 2 - Prohibits depends directly the ObjectManager, but all object can use factory object
As Magento prohibits depending on and directly using the ObjectManager, whether all object can use factory object to instantiate?
1
vote
1
answer
80
views
Duplicate codes sent to user - SELECT FOR UPDATE
Hi guys I am working an a site that sells electronic codes, the issue I am having is if two people order in the same few seconds they are BOTH sent the SAME codes.
I need a way editing it so when the ...
1
vote
1
answer
828
views
How to store value in object Magento 2
How do you change price in the frontend without affecting database. I have found the following code for it, but now I want to set my custom price in object.
Magento\Framework\Pricing\Amount\Base ...
8
votes
2
answers
2k
views
Plugins - is it bad habit to inherit from modified class in order to use protected properties
If I make plugin it is not neccessary to inherit from class I override. But, sometimes method I change uses properties that has protected access and they can't be used by plugin class.
But if I ...
5
votes
1
answer
10k
views
Magento2: Convert DataObject/Array into magento2 Collection?
How to convert the Data object into Magento2 Collection ?
In Mage1 we could do as below..
Mage1:
$collection = new Varien_Data_Collection();
foreach ($items as $item) {
$...
0
votes
1
answer
2k
views
Magento : how to get certain element value from array - object
below you can see the value genrate through print_r
when i am trying get value of
$post->PostContent() - return value is "post 1111111111111111Read More"
but i want to get second value that is - "...
2
votes
1
answer
3k
views
magento 2: where are methods ($_product->getResource()->getAttribute($_code)->getFrontend()->getValue($_product)) declared?
lets say in my catalog_product_view.xml I have this additional Block:
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.demo" template="product/view/warranty.phtml" ...
1
vote
1
answer
2k
views
magento 2 how to get object from selected product (then get attributes)
When a product gets clicked on -> the product details page opens and shows detailed information and images of the product. I want to display (programmatically) some custom product attributes(which I ...
1
vote
0
answers
27
views
Proxy object - when should I use them in fact
I have yesterday read great tutorial about Proxy objects:
http://alanstorm.com/magento_2_object_manager_proxy_objects/
I understand that I should use them to lazy load object which have can be slowly ...
3
votes
1
answer
96
views
How to learn about Magento objects
I recently started developing on magento2 and I'm finding a habitual problem always.
When I start creating new extension or something, it's normal I will need M2 objects on my controller's ...
3
votes
3
answers
888
views
Magento 2 Images from one .phtml to another .phtml
In a module I have installed I am trying to create a phtml page but can't work out how to pull through information(Like an image) to my new custom .phtml
File containing information:
view.phtml
<...
3
votes
2
answers
6k
views
Magento 2 get gallery images
I'm trying to pull through the gallery images on the product page as I'm re doing the gallery. The code I'm using is:
<?php $_product = $block->getProduct(); ?>
<?php $gallery = $_product-...
0
votes
1
answer
101
views
How to know what to write to pull through a product attribute Magento 2
Please excuse my ignorance as PHP 7 is completely new to me.
The more and more I work with Magento 2 the more I'm understanding objects.
But my question is:
You have objects the their contents such ...
2
votes
1
answer
2k
views
i need set flag in model save before event and get in model save after event in magento 2
I have Create two event model save before and after i get specific object and set flag in before model and get in after model.
for example
in before model
public function execute(\Magento\...
4
votes
2
answers
1k
views
How does Magento model distinguish column names in its get/set Model methods?
Let's say I have a Model associated to a table with a column called title. I understand that I can do a $model->setTitle("Hello"); to set a value to this field. I can probably do the same for ...
-1
votes
1
answer
6k
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.
17
votes
2
answers
18k
views
How to create varien object in magento 2?
In magento 1 we can create varien object like this
$collection = new Varien_Data_Collection();
$varienObject = new Varien_Object();
$varienObject->setData($data);
$varienObject->setItem($item);...