Magento PhpStorm "method not found in class" - magento

I just started to use PhpStorm and I am also not very familiar with Magento but just starting out.
Anyhow after getting all setup with git, my dev server and local database I am getting a lot of the errors: "Referenced method is not found in subject class".
This is not for all methods.. but it does seem to be a large portion of them.
What is causing this?
Some example methods: getProductUrl, getName, productAttribute, getRatingSummary, and on and on.

You should look to http://magicento.com/
This plugin will enable more autocompletion for Magento.
But there's some magic methods that not exists in the code, and of course, will no be clickable.
This plugins enables autocompletion in more than only just methods, it will enable it for templates names (in setTemplate), layout.xml block types, controller actions and more....
A must have when coding for Magento with phpStorm.
Basically, i will take a simple exemple, your IDE is not able to follow a model instansiation like this one:
$product = Mage::getModel('catalog/product')->load($productId);
When you do this, your IDE don't know that $product is an instance of Mage_Catalog_Model_Product. It should look into config.xml to resolve the classname. And so, you can't follow product methods.
Magicento enables this behavior.

Related

Override JE Quick Contact module in Joomla 3x

My client is using the module Je Quick Contact in their site, in Joomla 3.7.3
As default, the sender email is user's one, but in that way sometimes email goes in spams.
We would like to change it to have a generic send contact#domain.fr, seems we can't handle it in Back-office.
So I tried to override the module to change the sender email.
The module was in modules/mod_je_quickcontact and there there is files mod_je_quickcontact.php, index.html, mod_je_quickcontact.xml and folder CSS, JavaScript, PHP, images
In my template I created a folder mod_je_quickcontact and I put there all thoses elements, and I changed the file mod_je_quickcontact.php
But it's not working, it's still default data which are displayed.
I looked at Internet to see how to override, but for all example I found, in default module there is tmpl/default.php file to override. I don't have such folder and file.
Maybe I missed something or I did it wrong... I don't know what to do know, so, if someone has an idea, it would be great!
I think in Joomla there is only a way to override a template or layout of modules. The module you used is not best practice, because there are not using a default template (tmpl/default.php) to display the output of the module.
Like in Joomla docs mentioned:
The directory structure you need is: TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php
(Source: Joomla override documentation)
What I would do: Copy the module, change it in the way you need it. That´s it.
There have to be a difference between paid and free modules :-P

magento 2 custom phtml page

Having just got myself acquainted (enough) with Magento 1.9, and able to make the customisations required, I've been told that once it's out, we're moving to Magento v2.0.
Having found the differences in the file structure, I believe I can see where to place my code for the custom pages we use, but how can I add this page from my project to a static block for later use?
Previously, the method used was as follows (I realise this may not follow the best practise, but it worked):
Create element folder within theme or core templates directory.
eg. /app/design/frontend/<theme>/default/template/myelement/mypage.phtml
Add this page/element to a static block using the following in the content editor:
{{block type="<theme>/default" template="myelement/mypage.phtml"}}
This block can then be added to the category pages as required.
In Magento 2, I have tried what I believe to be required, which is replicating the file structure and adding phtml files to this, so the template file now resides in:
/app/code/<supplier>/<module>/view/frontend/templates/mypage.phtml
Adding to the content editor the following:
{{block type="<supplier>/<module>" template="mypage.phtml"}}
Unfortunately, this does not display the intended page (element). It doesn't display the calling "{{block" entry either, which usually happens when the line is invalid, so I can only assume that I'm missing something with the link to this template.
If anyone can offer some assistance with this, I would be most grateful.
EDIT:
Continued research on this has led me to the following assumptions:
Magento 2 requires more than just a new .phtml page, even for simple customizations.
I'm still missing something.....
Having gone through 3 different tutorials on creating new modules for Magento 2, each providing slightly different methods, but fundamentally being the same thing, I now have what I believe should be all the code elements to make a new .phtml template for display in a static block.
This has led to an additional problem though.
While I have the required code, I cannot add the module. Adding the module to etc/config.php, as suggested in 2 out of the 3 tutorials, simply crashed M2, both admin and frontend when you try to clear the cache. This is the case after manually clearing cache folders in the var directory.
Also, still unable to add the .phtml template file to a static block or page using content editor.
Not much hair left to pull out here, so looking for help! Thanks in advance
There are a few samples on GitHub, including https://github.com/magento/magento2-samples/tree/master/sample-module-newpage which shows a module adding a new page with a very simple PHTML template file. This example does not use CMS content editing however - it is a sample based on using layout files.
You mentioned you were getting crashes. Would need more details to help on that one. If you got it solved, could you update this question and accept a response to close it out? Thx!
You Should try "class" instead of "type". So your code should look like.
{{block class="<package>\<module>\Block\MyBlock" template="mypage.phtml"}}
You Should try "VenderName_Modulename::myelement/mypage.phtml" instead of "myelement/mypage.phtml". So your code should look like.
{{block class="VenderNameModulename\Block\MyBlock" template="VenderName_Modulename::myelement/mypage.phtml"}}

Payment modules not stored in VirtueMart

I have a huge problem with my VirtueMart. I try to develop a new payment module for it. The main problem is that no matter how I do it VirtueMart seems to refuse to let me store the plug-in in the database and also it refuses to let me choose it as a payment method.
I have disabled all other "countries" except the one that the module is written for. I have followed all guides on joomla mastery. I am convinced that my constructor is correct according to the scarce documentation I have found. I have even copy/pasted an existing payment module and changed all names for the database to something different so I can see if it's created and it's a no-go.
I am starting to get desperate. Does anyone have a good virtuemart developer guide? Do I need to turn some flags on (the flag to update/write to database is on in joomla and virtuemart) or off? How can I programatically FORCE VirtueMart to actually listen to what it say should work in all documentations I've found?

What is the role of applyDesign in magento

I am using magento 1.7. I am working on extension for quick view of product. I am unable to understand the following code.
Mage::getModel('catalog/design')->applyDesign($product, Mage_Catalog_Model_Design::APPLY_FOR_PRODUCT);
can anybody tell me what is the purpose of this function applyDesign because i have tried comment this line but no change happened so i am wondering why this code used for ????
Ref. Mage_Catalog_Model_Design::applyDesign() (link).
It's a deprecated method for applying the package+theme design settings which can be set at the product level. If you are not seeing a change, it is because there is no entity-level data set for that entity (which is normal).

Work with the cart in the billing.phtml

inside the checkout onepage billing.phtml I have to do several checks and even remove or add stuff to the cart.
But I don't seem to find how to do that
how can I change the cart from within an template?
Thanks,
Joe
I would recommend that you don't apply these logic changes in the phtml. You should try to work with the Shipping or Payment method PHP code, either by extending Magento's core methods or writing your own. There are numerous tutorials on the Magento wiki or other blogs on how to achieve this.
By editing the phtml directly, you run the risk of breaking when Magento releases patches or upgrades, and it is bad practice in general.
From that file you can use $this->getQuote() to get a Mage_Sales_Model_Quote object. Methods you might find useful on that object are getAllItems(), addItem() and removeItem().

Resources