Questions tagged [code]
The code tag has no usage guidance.
120
questions
40
votes
5answers
7k views
Magento coding standards
I recently started working extensively with Magento and Code sniffer, and I would like to know which standards I should follow.
I tried Zend coding standards, but I don't want to use the 80 line ...
27
votes
5answers
10k views
Why does Magento have 3 code pools?
Magento has three code pools:
community
core
local
Core: It contains all Magento default modules
Community and local: We use these code pools for our custom module development.
Now I have doubt ...
15
votes
2answers
2k views
What do “#@+” & “#@-” strings mean in the comments?
I see a lot of "#@+" & "#@-" strings in the comments of the some Magento 2 classes.
\Magento\Customer\Api\Data\AttributeMetadataInterface
interface AttributeMetadataInterface extends \Magento\...
11
votes
1answer
262 views
Does removing commented code speed up a Magento site?
In most (if not all) Magento files, there is commented disclaimers:
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with ...
11
votes
2answers
14k views
Magento multiple order on one checkout or order splitting
Store products are supplied from different vendors. It is required to create multiple order for every vendor based on its products in the cart during one checkout. Is there any extension to achieve ...
5
votes
2answers
14k views
Programmatically create a credit memo
Given an order that has been invoiced (by cash on delivery for testing) and is in state "processing", how can I create a credit memo for a given sku and quantity (in code that is outside of Magento ...
5
votes
2answers
2k views
What is meant for Vanila magento 1 codebase?
I am trying to migrate from magento 1 to magento 2 and I have seen on magento website there is a tool for that which is code migration toolkit here's link for the same https://github.com/magento/code-...
5
votes
2answers
384 views
Argument replacement not working for type object
I am trying to replace an object using Argument Replacement but unfortunately I am unable to do so for type:object.
Every time I am getting error:
1 exception(s):
Exception #0 (Magento\Framework\...
4
votes
3answers
488 views
Can anybody explain me about following code?
Some days back I found this code in one of my application file.
I am using git in my server so I can found modified file easily. I checked it but I am not getting what this piece of code does exactly.
...
3
votes
3answers
783 views
In this code what this customer parameter means
In this code what this customer parameter mean
$this->helper('customer')->getRegisterPostUrl();
3
votes
1answer
137 views
Magento 2 core functionalities and structure - difference between vendor/magento/framework and vendor/magento/module-* namespace code?
What is the difference and when to use vendor/magento/framework code, and when to use the vendor/magento/module-* code?
3
votes
1answer
138 views
Where does Magento implement methods?
I am new to Magento. I have following code in a template file called brand.html
$brandImageUrl = $this->getBrandImageUrl($brand);
My understanding (roughly) is that $this refers to an instance of ...
3
votes
1answer
2k views
Using Magento as backend ONLY for website
I want to use my own frontend for my website, and only use Magento for the cart and backend. Most of the site is not a commerce site and I don't want Magento taking it all over. I've read about how to ...
3
votes
1answer
592 views
Learning Magento from reviewing the core files
Prior to using Magento I had only used procedural programming techniques (and the code I wrote was very rarely reusable), although I was aware of oo, I had never had the need to use it, let alone use ...
2
votes
2answers
2k views
Going from Admin Panel to Source Code and finding out what is running under the hood
I have a simple example. Say my system is messed up and I want to disable the cache
manually because my admin panel is not working. How do I go from figuring out what
component is run, and what php I ...
2
votes
2answers
15k views
How can I write this sql query following the Magento Way?
How can I write this unsecure, ugly, query following the Magento way without using collection?
select (select sum(points) FROM ".$this->getTable('mymodule/registry')." where points < 0 and ...
2
votes
1answer
101 views
Where is translation for XML configurations is happening in the code?
In XML files (such as system.xml) I can specify a translate attribute for nodes to be translated. Where is this translation taking place in the code?
2
votes
1answer
3k views
Get attribute code from attribute value
Suppose color and price and manufacturer are three attribute codes.
black and blue are attribute values for color.
$0-100 and &101-200 are attribute values for price.
hp and dell are attribute ...
2
votes
1answer
939 views
Create custom voucher code after order
is it possible with Magento (1.9) to create a custom, 10-digit, voucher code for a user/order after the order was placed and paid?
I also need to output it in the PDF or in the user backend.
I need ...
2
votes
1answer
35 views
Add a block to programmatically generated widget
I need to generate a widget block with upgradeData.php and assign a block to this widget how can I do this?
Folowing is my code for widget generation:
Setup/UpgradeData.php
public function ...
2
votes
1answer
4k views
Downloading order details through Mage::getModel('sales/order')
I am trying to download order details (email + name) from my stores. We have a multi-store.
The problem that I have is that when I run this code on STORE 1 or STORE 2 - both result in the full ...
2
votes
1answer
50 views
How to know all available methods and how to use them [closed]
I'm still learning how to use Magento and I see that it has lots of useful methods. However, my only way of learning that a method exists, and how to use it, remains looking at code that's already ...
2
votes
1answer
112 views
How can i use code from other pages into current page?
a question what can be useful to know is
how to use code from other pages into the current page you
are working on?
e.g. I want to echo the total product count of the search query on
list.phtml
...
2
votes
1answer
747 views
Add Country Manually in Customer A/c Details
How can we set Country in Customer A/c Details Manually.
I am trying to execute code as following and
So Please Suggest Answer in that criteria :
if (!$customer->getId()) {
$...
2
votes
1answer
415 views
Change catalog product layout view by code?
My catalog product use 3 Columns Layout. The layered navigation in the right The product in the center The cart in the left. my problem when i don't have a product in the category the right column is ...
2
votes
0answers
25 views
Add Product Name to Advanced Pricing Export
I'm attempting to add the "Product Name" attribute export the Advanced Price List in Magento 2.3.4 but I cannot seem to get it to work.
I am attempting to modify the AdvancedPricing.php ...
2
votes
0answers
25 views
How to add a text on Homepage using module (code) [closed]
Need help writing a code for adding text on Homepage.
I'm running Magento 2 on localhost
2
votes
0answers
35 views
Transfer to other server
I want to transfer to other server my store (new server have plesk panel ).
I wrote command in cli
bin/magento setup:backup --code --media --db
from old server with this method can i take those ...
2
votes
1answer
430 views
How to add video block in category page
I want edit layout in category list page. need to create video content in this page for each category
example
help me please. thx XD
2
votes
1answer
2k views
Show State/Province code in address
When a customer make an order, in the shipping and billing address appears the extended Province name (for example "Lecce"). Is it possible to show the Region code "LE" instead of the Region name "...
2
votes
1answer
536 views
Location of the code of the currency switcher
The getSwitchCurrencyUrl() method creates a link like this:
http://myshop//directory/currency/switch/currency/USD/uenc/aHR0cDovL...
Where can I find the currency switch code which is called when I ...
1
vote
2answers
85 views
Does anyone have any example code or recommended plug ins for adding the rel=prev and rel=next tags for paginationN
Does anyone have any example code they have used in magento to implement the rel=prev and rel=next tags for paginated content on a magento site?
or if you have a recommended plug in?
1
vote
1answer
214 views
get array of a product's assigned/used attributes?
what is the easiest way to start from a product instance and get a list of the attributes both standard and custom, set for that particular product ?
thank you.
1
vote
2answers
130 views
Broken website layout
Does anyone know what part of this code is causing the page layout to break? The layout goes wrong just under Revolution slider and around the parallax section.
It did work fine but I tried to edit ...
1
vote
1answer
223 views
Magento2 I want to change “Please specify the zip code.” error message on one step checkout Canada post method
Magento2 I want to change "Please specify the zip code." error message on one step checkout Canada post method
Thank you,
1
vote
1answer
2k views
Slider not showing
Im very new to Magento and programming. My skills are very limited, but i have managed to set up a copy of a website by doing the following.
I made a copy of the SQL database and FTP from this site ...
1
vote
1answer
54 views
Magento 2: How to Improve Code In Magento (PHP)?
I'm new to Magento just, I'm working on an event I call many files through object manager, but I know that's not a good way, I have a chunk of code just need to know how can I improve it.
...
1
vote
1answer
149 views
CE v1.9.3.4 (v2) did NOT fix the “Enable Form Key Validation On Checkout” Was released July 12,2017
@Ryan-hoerr YESTERDAY sent out message that there was v2 Patch or upgrade to v1.9.3.4 from v1.9.3.3 because of the form_key checkout problem which the Magento CE 1.9.3.4 Release Notes was supposed to ...
1
vote
1answer
39 views
Need help on writing magento code for fetching data for this custom mysql query
Customizing IWD_SalesRepresentative extension in their reports I want more data than they give by default
Their default code:
$colunms = $this->_getSelectedColumns();
$this->getSelect()...
1
vote
1answer
26 views
Why is magento breking apart this h1?
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?> - <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), '...
1
vote
1answer
237 views
Put icon before sub category
I'd like to put font awsome icon before al my level2 menu
Exemple :
Menu 1 (on mouse)
Submenu 1
(icon) Submenu 2
(icon) Submenu 3
(icon) Submenu 4
But I can't figure out where the file is, I've ...
1
vote
1answer
2k views
How do I change the text color of the Search the entire Store Here text in search box [closed]
I have figured out several places and ways to change the actual text, but can't seem to figure out how to change the color of the text. Any help would be appreciated.
I am pretty new to Magento, I ...
1
vote
1answer
23 views
syntax error with string values
i tried below code :
$helper = Mage::helper('catalog/product_view')->getvalofk('Mark');
i get result but when i call it dynamically like
$helper = Mage::helper('catalog/product_view')->...
1
vote
1answer
2k views
Admin Grid Not Displaying and Collection returning false value
I am creating a small admin module. When i did var_dump($collection) in my Grid.php file i get false value. Also i am not able to see the grid too.
Moreover, i am able to see my header text and ...
1
vote
1answer
2k views
Registration and sent coupon code
If user register with website and send to the coupon code for that customer.
How to get the coupon code and sent to the customer?
Is it possible to generate coupon code automatically?
1
vote
1answer
1k views
What is getFormattedOptionValue Vs. getFormatedOptionValue?
Is this just a legacy typo? Or is there something that I'm missing. I just noticed this in the file:
code/local/Mage/Checkout/Block/Cart/Item/Renderer.php
public function getFormatedOptionValue($...
1
vote
2answers
124 views
Do I Have to Copy the Full Class to the “local” code pool when Making Modifications
Can someone please answer this for me.
If I create my own version of a Mage/core file in the local code pool, does it completely overwrite the Mage/core file? Or will the methods that have not been ...
1
vote
0answers
37 views
Magento2 Mageplaza LayeredNavigation multiselect filter with AND condition [closed]
I am working on a project which uses Mageplaza Layered Navigation. I need to change the behavior of multiselect from OR to AND.
As an example, I create attribute color. When I search for red and ...
1
vote
0answers
32 views
Checkout Page not loading and getting blank page
first, I apologize for not being a programmer and not being able to publicly post the URL in question.
The checkout process gets empty in the second process page.
I assume Initialization code laods ...
1
vote
1answer
41 views
Problem adding Google Analytics Code and Facebook pixel in Magento Community 1.9.3 [closed]
Our site was hacked a while back and ever since we 'brought it back' we are unable to add Google Analytics code or a new Facebook pixel in - System/Configuration/General/Design/HTML Head/Miscellaneous ...