Questions tagged [php]

This tag is used for questions that involve PHP code in any way. So as soon there is a PHP Exception returned or error report generated, this question qualifies to be tagged with PHP.

Filter by
Sorted by
Tagged with
4
votes
3answers
2k views

Implementing enhanced ecommerce with Google Tag Manager

I want to implement enhanced ecommerce with Google tag manager on Magento. I'm not a developer but i can play around with files and backend if instructed. I don't know how to send dataLayer for ...
4
votes
3answers
3k views

How to copy a product's attributes value to another attribute?

i want to copy a product's attribute (weight) to another atribute (general_weight). i found this codes, but i don't know what to do with this codes? or where to copy them? $prod=Mage::getModel('...
4
votes
1answer
5k views

Get product prices with multiple websites

I have setup my Magento with 2 websites, with ID 1 and 4, and one store for each website. My product has 3 prices: a Default price, and a price for each website. How can I get these 3 prices ...
4
votes
2answers
9k views

Code before a controller's action is executed?

I would like to write some custom code before any actions in a controller is executed. It would seem like an easy one, but i am unable to find help anywhere in google. I tried to override preDispatch()...
4
votes
2answers
139 views

Issues on create Magento 2 module

I create a module for Magento 2 to add a custom javascript to the theme head but my custom js file is loaded in front off all javascript files and this come with the error: ReferenceError: jQuery is ...
4
votes
2answers
13k views

Programmatically add Custom Product Attribute to attribute set

Is there a way to add a custom Attribute (DB-Column, whatever) to product attribute sets? I tried the following but it I get the error 'Wrong Entity ID': /** @var Mage_Catalog_Model_Resource_Setup $...
4
votes
1answer
3k views

How to get quantity of simple product on configurable product page

I'm searching the way to preload quantity of each simple product on configurable product detail page. The reason is I want to dynamically show to client "In Stock", "Out of stock" or "Only 1 left" ...
4
votes
1answer
926 views

What are the equivalents of magento 1.x models in magento 2.x

I am new to magento2 and I am finding it very difficult to get the regular code snippets right in the new version. So, please help me out here and explain the equivalents of the following snippets in ...
4
votes
2answers
743 views

Magento 2: Can you use a Plugin with the `Psr\Log\LoggerInterface` type?

I've got a di.xml that looks something like this <config> <type name="Psr\Log\LoggerInterface"> <plugin name="namespace_modulename_plugins_psr" type="...
4
votes
2answers
12k views

get order details by Order Id in magento [duplicate]

I am trying to get order details by order id in my code. For this I have created a php file and copy that file to a folder in public_html. this is my code : <?php error_reporting( E_ALL ); ...
4
votes
4answers
16k views

Call static block into another static block through template

I want to call a static block into another static block if the right conditions are met. I believe that my main problem is how to register the template in XML, as I never worked with it before. First ...
4
votes
2answers
2k views

magento 2 / can't set addImageToMediaGallery path

i created php file in root folder and trying to create simple product programatically in magento 2. testimg folder locating in root. I always thow the error: The image does not exist. Here is code: $...
4
votes
1answer
598 views

Magento 2 Replacement for cms/template Object

In Magento 1, if you wanted to transform an arbitrary block of text, the same as the body of a CMS page or block might be changed, you could use the following model class Mage::getModel('cms/template'...
4
votes
2answers
5k views

Upgrade PHP version problem

I am running an old version of Magento - 1.3.1 Now - I would like to install the newest version (1.9.1) for a new store (different domain) on the same server. I have done that and it works. However, ...
4
votes
3answers
5k views

Add standard captcha to registration page

I want to add the standard captcha from Magento to our customer registration page. Now I saw that you can enable this captcha in the configuration (System -> Configuration -> Customer Configuration -> ...
4
votes
2answers
5k views

Show layered subcategories on the left of the subcategories page

I am having an issue. I need to show the sub-category layered navigation on the SUBCATEGORY page of a store that I am working on. You guys already know that on the subcategory layered navigation is ...
4
votes
3answers
8k views

how to add a product in cart from external php file in magento?

i've an external php file called addtocart.php who is located in my magento root folder. with this file i want to add a product to the cart. the product should have the following attributes: sku name ...
4
votes
2answers
374 views

Magento-2:Class Magento\Framework\App\Http\Interceptor does not exist

Exception.log file Error: {"exception":"[object] (ReflectionException(code: -1): Class Magento\Framework\App\Http\Interceptor does not exist
4
votes
3answers
4k views

Magento product stock alert cron job

I recently discovered my product stock alert e-mails aren't being sent. When I checked the cron_schedule table in my DB, I see the following: Which basically tells me there hasn't been any execution ...
4
votes
2answers
507 views

Split the quantity box into three categories

I want to split the quantity text box into three text boxes,i.e., for child, adult and others separatly before add to cart for only bundled products. I did by adding the following code in the ...
4
votes
2answers
599 views

Get a list of all blocks with their names

I'm trying to find a way to get a list of all magento 1.9 blocks with their names programmatically. I.e: $blocks= [ 'core/text_tag_css_admin' => 'Mage_Core_Block_Text_Tag_Css_Admin', '...
4
votes
2answers
2k views

How should i get the count of products in wishlist?

<li class="trigger-item"> <?php $moduleName = 'wishlist'; $cartCount = Mage::helper('checkout/cart')->getCart()->getSummaryQty();?> <?php if ($this->helper('...
4
votes
3answers
2k views

Magento CE 1.9 Add Product to Cart

I am making rest api's for add product to cart for that I wrote this code: public function _create(array $data) { $id = $data['id']; $qty = $data['qty']; $product = Mage::...
4
votes
3answers
3k views

ad thumbnail to aw blog posts

im trying to add a thumbnail image to aw blog posts header and into the aw blog sidebar widget next to the each headline i did these: In app/code/community/AW/Blog/Block/Manage/Blog/Edit/Form.php ...
4
votes
3answers
6k views

Magento how to get subtotal session value in custom module?

I am currenly working on one custom module for magento 1.9.1 I am stuck on getting the session value of the checkouts subtotal. I know how to get it in a template file but i have to get in in a ...
4
votes
2answers
154 views

Custom Code Mobile View Slider not working in iphone and well supported in Android

My Code : <div> <center><pre style=" margin-bottom: 0px; font-size: 15px; color: #166fb0; padding-bottom: 5px; padding-top: 5px; border-bottom-width: 0px; ...
4
votes
2answers
4k views

magento 2 - backend page with tab and form on custom module

I created my custom module for backend, I created the controller, I added the link on standard menu and the acl configuration, all these part works fine. Now I'm trying to add a tab list on the left ...
4
votes
1answer
2k views

Set minimum order price for a shipping method

I want to set a minimum order amount for a specific shipping method. I want a specific shipping method to get enable when subtotal price of order reaches to the specific price which I had set before ...
4
votes
3answers
8k views

Magento place order redirects to shopping cart empty

I just changed my server, all the files and database are the same i had previously. Now all of sudden i am having this issue. I add item to cart, go to checkout page, click on place order and magento ...
4
votes
3answers
4k views

Can't Update product attribute from magento admin panel [closed]

After editing short description from magento admin panel and clicking on save, it shows message that it was saved successfully, but the short description was same before editing. I hope this issue is ...
4
votes
1answer
45 views

Where to place Mobile detect code?

I saw this method as efective to detect if the user is using a mobile device: $isMobile = Zend_Http_UserAgent_Mobile::match( Mage::helper('core/http')->getHttpUserAgent(), $_SERVER ); But ...
4
votes
1answer
551 views

Magento 2 display a category's product listing with its layered navigation on home page?

I am using Magento 2.2.2 I want to display a particular category products on homepage along with its respective layered navigation. What I have already tried: 1) Changed home page layout to "2 ...
4
votes
2answers
313 views

Add size chart in magento 2.1

Is there a way to add size chart in magento 2.1. I am new with magento and I am having trouble figuring out the cms. So, the client asked me to add size chart on single product. Any suggestion will be ...
4
votes
1answer
994 views

Fatal error: Class 'Varien_Profiler' not found in /app/Mage.php [closed]

So this is an odd one. I am running Magento EE 1.14.2.1 with php 5.5.34 with Zend OPcache. I installed AOE Profiler and fixed a few issues and now I wanted to uninstall. So I removed all files, ...
4
votes
1answer
2k views

Magento API - Category Create - Default Product Listing Sort by does not exist

Fatal error: Uncaught SoapFault exception: [1] Default Product Listing Sort by does not exist in Available Product Listing Sort By. I cannot figure out why Magento keeps giving me this error? Using ...
4
votes
2answers
90 views

Menu that open by itself after clicking on the link of a parent category

When I click on parent category, the page load but the menu re-open if the pointer of the mouse is still present. What do you recommend so that the menu does not re-open immediately ? I found PHP of ...
4
votes
0answers
103 views

Knockout.js in magento2

How to change the jquery into ko? define([ 'jquery' ], function ($) { "use strict"; $.widget('xxx.homePage', { options: { bindSubmit: true, ...
4
votes
2answers
1k views

Magento 2 - After adding to cart, cart page showing empty

I have a magento 2 website and I am facing an issue where After you add to cart, cart page is showing empty. It's not happening all the time but most of the customers are facing this issue. Thanks
4
votes
1answer
602 views

Magento 2.1 update special price dates programmatically

I have a problem updating the special price dates of a simple product. I've tried 2 versions of code, but without results. In both cases the special price will be update, but no affect to the start ...
4
votes
1answer
894 views

cannot get extension attributes value

The value can post However,I cannot get Extension attributes on my plugin which intercept Checkout success controller code. getExtensionAttributes always return null <?php namespace Genning\...
4
votes
0answers
11k views

What is the optimal setting for max_execution_time? [closed]

I'm looking at improving our server performance, and noticed that the stock EE .htaccess file sets the max_execution_time to 18000, which really seems like a typo. 18000 seconds is 5 hours. Should ...
3
votes
2answers
20k views

Can't find where to change meta description, keywords and title

I've checked in both the admin area configuration > design > HTML Head. The current title, description and keywords currently don't come from here although in the backend file head.phtml the code ...
3
votes
3answers
5k views

Magento reindex from command line, still having timeout error

I'm trying to reindex my catalog_url_rewrite table (Magento website) through the command line using the command "php indexer.php --reindex catalog_url" in /shell. I get the following error: PHP Fatal ...
3
votes
4answers
5k views

Magento Website Hacked - encryption code in all php files

Our website getting hacked again and again with some encryption code in all php files. I don't know why and how it's hacked. I want to know if someone can debug and provide some needy solutions. ...
3
votes
3answers
3k views

magento2.2 - programmatically create coupon

in a magento 2.2 based site we need to programmatically create a coupon code for . However was only able to find one code sample and it does not seem to work. Meaning no coupon code is created and ...
3
votes
2answers
8k views

Get page title in Magento 2

I want to get the page title in a PHTML template file. Is there a global function I can call to retrieve this?
3
votes
2answers
5k views

Magento 2: Import CSV File Size

When we import Product CSV from Admin it says Make sure your file isn't more than 2M. How to increase this size? I have 5M file size. Don't want to create multiple CSV files with each 2M
3
votes
1answer
4k views

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry - Magento 2

I'm trying to setup my crons for Magento 2.2.2, but nothing seems to be updating. I have created cron in cPanel, like below, each once per minute: /usr/local/bin/php /home/userishere/public_html/bin/...
3
votes
2answers
559 views

Sessions adding up to ~256MB+ per day, is this too much and if so can it be prevented?

On of Magento sites is currently building up sessions files fairly fast and I'm having to clear it once or twice a day just to be safe. The reason for this is because I put sessions in RAM which means ...
3
votes
2answers
6k views

Get disabled/inactive products from flat catalog product strucutre

I am trying to get all disabled products from magento using the following code but it returns only enabled products. I have enabled Flat Catalog Product options. Is there any way to get disabled ...