Hot answers tagged

13

You can try following way to create new block inside controller <?php namespace [Vendor]\[Module]\Controller\[ControllerName]; use Magento\Framework\App\Action\Context; class [YourControllerAction] extends \Magento\Framework\App\Action\Action { /** * Index constructor. * * @param Context $context */ public function ...


11

There are several methods available to do that. But i will prefer second one. 1 Core block override 2 Event/Observer So, once you have created your module, you will need to declare the observer in your config.xml: <!-- config xml --> <frontend> <events> <controller_action_layout_render_before_review_product_list>...


6

You can use helper to get dynamic label. Add helper in <argument/> and chnage xsi:type="string" to xsi:type="helper" <argument name="label" xsi:type="helper" helper="Vendor\Module\Helper\Data::getLabel"></argument> In your helper, you can get dynamic label like this <?php namespace Vendor\Module\Helper; class ...


5

You can create it by with the help of Magento\Framework\App\RouterList. For this you need to create di.xml in your module (I am assuming that you know how to create module in M2). First create di.xml in below path, app/code/yourvendor/yourmodule/etc/frontend/di.xml In this file add <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...


4

Under /app/code/community/Fishpig/Wordpress/Model, you should find some files including these fields. Post.php accesses post data User.php accesses author data Term.php accesses category data From your description, most of the information you're looking for will be in Post.php and User.php Examples: From the post view and any other pages with access to ...


4

If you want to set specific theme for all action of controller you can add in controller protected function _construct(){ parent::_construct(); Mage::getDesign()->setArea('frontend') //Area (frontend|adminhtml) ->setPackageName('packagename') //Name of Package ->setTheme('default');// Name of theme } If you want to set for specific ...


2

You can easy change the theme at controller using below code: Mage::getSingleton('core/design_package') ->setPackageName($package) ->setTheme($theme); Where $package is package name of your theme like rwd,default,base etc. and $theme is default,base,iphone etc basic of package. Note: You should call this ...


2

If you're comfortable with widgets, you can create a widget for this. In your widget block file, you can inject an instance of \Magento\Checkout\Helper\Cart so you can use the helper functions around the cart state. You can then override the ::_toHtml() method like so: protected function _toHtml() { if (0 === $this->_checkoutCartHelper->...


1

Try Below code to get all SKUs Update: Instead of Using multiple foreach loop, you can use PHP in_array function. <?php public function isCartaoAddAction(){ $categoryId = 13; $collection = Mage::getModel('catalog/category') ->load($categoryId) ->getProductCollection(); foreach($collection as $product){ ...


1

simple is that add this in attribute array visible' => true, and use the attribute_code as the field name. magento autosave the value.


1

You can use widgets instead of hardcoded html. Also you can call phtml from cms page and add your own code or logic for product collection and there you can easily show the dynamic price, name, images etc. You can phtml file from cms pages by using below code: {{block class="Magento\Framework\View\Element\Template" template="[VendorName]_[ModuleName]::[...


1

As per your initial question: Step 1 . In /var/www/html/magento2/app/code/Companyname/ModuleName/Block/dynamiccss.php In this file we get the css values like below : public function color_right_headingh() { return $this->_helper->color_right_headingh(); } Step 2: In /var/www/html/magento2/app/code/Companyname/ModuleName/Helper/Data.php ...


1

Your js code is not working because when it is run the element you are searching for is not yet rendered by knockout js. You can call you code in following snippet to see if it works ; <script> require(['uiRegistry'], function (r) { r.get("product_form.product_form.product-details.quantity_and_stock_status_qty.qty", function (el) { // call ...


1

Yes, you have to create your phtml file then you include it in the page that you want, with xml or directly in a page code, then you customize it with js for exemple. To include it: 1) You create the phtml file app/design/frontend/{package}/{theme}/template/catalog/product/homeproducts.phtml then you add your custom code 2) to include it via cms page: {{...


1

You can do it by Ajax e.g. add this in your template file : jQuery(window).load(function() { jQuery.get( "http://example.com/mymodule/index/some", function( data ) { console.log(data); // replace this output in your page }); }); Create a function in any controller then add this code e.g. class Paras_Mymodule_IndexController extends ...


1

you can set theme like that on front-end.. Mage::getDesign()->setArea('frontend') //Area (frontend|adminhtml) ->setPackageName('default') //Name of Package ->setTheme('modern');


1

You cannot set it from the database. You will have to code for it. You can make use of the after_element_html feature that the form builder offers. So declaring a field like this: $fieldset->addField('identifier_here', 'type_here', array( 'name' => 'name_here', 'label' => 'Label here', 'required' => true|...


Only top voted, non community-wiki answers of a minimum length are eligible