texts: Programmatically open product listing with filters enabled

texts:
Is it possible to open the product listing page in backend enabling some filter?

In particular, I have a custom module with an observer linked to a controller_action_predispatch event. In the observer I need to evaluate a product and, if some conditions are met, I need to redirect to the product listing page showing just that product, like in this picture

This is (partial) code from my observer

public function execute(\Magento\Framework\Event\Observer $observer)
{
    $product = // ...retrieve product

    if ($this->conditionsAreMet($product)) { // check my conditions

        $url = $this->backendUrl->getUrl(
            'catalog/product/index',
            [
                'filters' => [
                    'entity_id' => [
                        'from' => $product->getId(),
                        'to' => $product->getId()
                    ]
                ]
            ]
        );

        $action = $observer->getControllerAction();
        $action->getResponse()->setRedirect($url);
    }

    // ...
}

It doesn't work, it just redirect to the product listing, without applying any filter. If I want to open the product edit page, I can call getUrl() with

$url = $this->backendUrl->getUrl(
    'catalog/product/edit',
    [
        'id' => $product->getId()
    ]
);

and this works. However I'm not able to set the filters before redirecting


texts: Always update on duplicate when using save() in custom model

texts:
I have a custom model linked to a custom table. In that table, the column sku is unique. I'd like the following code to always update on duplicate:

Mage::getModel('company/product_log')
  ->setData('sku', 'abc123')
  ->setData('error', 'Invalid price.')
  ->save();

I'd like to do this from within the model itself instead of having to repeat update-vs-insert logic everywhere I want to use this table.

What is the best way to do this, or an existing example already in Magento?


texts:
My system.xml in /etc/adminhtml is the reason for this error

<field id="vendor_role" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>User Roles</label><source_model>Admin\Role\Model\System\Config\Source\Roles</source_model>
</field>

 Warning: DOMXPath::query(): Invalid expression in /home/mysite/public_html/vendor/magento/framework/Config/Dom.php on line 273


texts:
My store was extremely slow on the product pages and after a little bit of debugging I found that the product swatches were causing the problem.

I've checked the server error log and the max_execution_time exceeds with the following code snippets:

/app/code/core/Mage/ConfigurableSwatches/Helper/Data.php

public static function normalizeKey($key) {
    if (function_exists('mb_strtolower')) {
        return trim(mb_strtolower($key, 'UTF-8')); // The line the error refers to
    }
    return trim(strtolower($key));
}

/app/code/core/Mage/ConfigurableSwatches/Helper/MediaFallBack.php

$optionLabels = array_map(function ($value) {
    return array_map('Mage_ConfigurableSwatches_Helper_Data::normalizeKey', $value); // Error
}, $optionLabels);

My client does prefer to have the swatches enabled on the site and the swatches are used for three attributes, but how can I solve the executing time problem or just generally speed up the swatches?

I'm using Magento 1.9.1 with the default swatches and the site runs on an nGinx server


texts: How to show discount on all products without applying it in checkout page

texts:
I want to show X percent discount on all products in my website. I dont want to apply that on checkout page. Just only want to show visually like below image

Is there any way to show this ?

Actually my problem is when i apply site wide discount from catalog price rules after that if we apply coupon code then it discounts the discounted product (with catalog price rule) on checkout page. how to fix this?


texts: Change color add to cart button (flexgrid)

texts:
I've been looking everywhere to change the css of this 'add to cart' button. The selector is .addtocart but when i change the css nothing changes...

.addtocart{
background-color: green;
}

I also cant find it anywhere in the css files.


texts: my 2.2.6 magento checkout page do not display firstname,postcode,and telephone input field

texts:
My current version is magento 2.2.6 and i am facing a strange issue.

  My checkout page do not display firstname,postcode,and telephone input
  field on checkout page.

whenever i try to place order it gives message

  "firstname and telephone are required field".

I have disabled all custom extensions and default checkout method is also not displaying those fields.
what should i do to display those fields in checkout page.
Any one help would be appreciated.


texts: Magento 1.9.4.1 Invoice emails are sent before the order confirmation emails are sent

texts:
After placing an order in Magento 1.9.4.1, an order receives the status of 'Processing'. The funny thing is that Invoice emails are sent immediately, and a couple fo minutes later, the order confirmation emails are sent.

Both (order confirmations emails and order emails) are enabled. Has anyone had experienced these issues before? It should be the other way around (so order confirmation emails first, and then the invoice emails)


texts: Help with attribute on front-end and php code

texts:
So I have an attribute showing up on front end for each product.

Front-end (Currently): 1: http://i.stack.imgur.com/bEVcq.png

What I need: 1: http://i.stack.imgur.com/COctc.png

Back-end code:

<h style="color:#93c455;">✓</h><?php $features = $_product->getAttributeText('features');?>
<?php echo implode("
 ✓ ", $features) ;?>

What do I need to achieve this? I need all the attributes showing with different icons next to them. I need all attributes showing and a green check mark on those that are selected on admin, and I need the the text of those not selected to be less opacity than the ones that are selected.

Can anyone help with this?

This is how my admin looks....


texts: getData() not working on cart item magento 1

texts:
I am fetching cart item on following .phtml file

  frontend/base/default/template/checkout/cart/shipping.phtml

by using the below code

$cart = Mage::getModel('checkout/cart')->getQuote();
echo "
";print_r($cart->getData());echo "
";

I get an array of cart item but when I use the below code

foreach ($cart->getAllItems() as $item) {
   echo "
";print_r($item->getData());echo "
";
}

then on the frontend the page keeps loading for some time and then returns nothing.

I'm not getting anything just an empty white screen.

Nothing loads on the page. But when I use this

foreach ($cart->getAllItems() as $item) {
   echo $item->getProductId();
}

then I get the ids of the products in the cart.
Could anyone tell me the reason why it is happening, why getData() is not working but I am able to use getProductId() or getProductName().


texts: Magento 2:How to change default custom module path from app/code to app/customdiretory

texts:
How to change default custom module path from

  app/code

To

  customdiretory


texts:
In the checkout page, I'm making a check to see it the user is logged in and if he's not, then a pop up window appears with log in details. The log in form that I pop up is from the file customer/form/mini.login.phtml. However when I press the submit button nothing at all happens. With a little search I found out that I need to add the form_key in the mini.login.phtml file. So the code snippet I'm adding is:

 <input name="form_key" type="hidden"
 value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />

I use Ctrl+R to reload the page and remove the cache but still nothing happens.

Any hint would be helpful. Thanks


texts:
When I am trying to ship an item I get the message "Not all of your products are available in the requested quantity."

The order comes through Magento 2 into Linnworks which allocated the stock and after a set time pushes a stock update to Magento. This means that in some cases the item on Magento is now below a minimum level, the item cannot be shipped due to this.

Is there a way to just bypass the error for just the ship section. Such as disabling the validation for backend shipping?


texts: Magento 2 hide links in my account page conditionally

texts:
Hi guys i am trying to hide few links under the customer navigation panel conditionally.

i have these setup done.

customer_account.xml

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="customer_account_navigation">
        <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-create-agent-createagent">
            <arguments>
               <argument name="path" xsi:type="string">my/agent/createagent</argument>
               <argument name="label" xsi:type="string">Create Agent</argument>
            </arguments>
        </block>
        <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-create-agent-viewagent">
            <arguments>
               <argument name="path" xsi:type="string">my/agent/viewagent</argument>
               <argument name="label" xsi:type="string">View Agent</argument>
            </arguments>
        </block>
    </referenceBlock>
</body>
</page>

current.php

<?php

namespace [vendorname]\[module]\Block\Agent;
// namespace Namespace\Module\Block\View\Element\Html\Link;

//use Magento\Customer\Model\Session as CustomerSession;

class Current extends \Magento\Framework\View\Element\Html\Link\Current{

protected $_customerSession;
/**
 * Constructor
 *
 * @param \Magento\Framework\View\Element\Template\Context $context
 * @param \Magento\Framework\App\DefaultPathInterface $defaultPath
 * @param array $data
 */
public function __construct(
    \Magento\Framework\View\Element\Template\Context $context,
    \Magento\Framework\App\DefaultPathInterface $defaultPath,
    \Magento\Customer\Model\Session $CustomerSession,
    array $data = []
) {
    parent::__construct($context, $data);
    $this->_defaultPath = $defaultPath;
    $this->_customerSession = $CustomerSession;
}

public function toHtml(){

      if($this->_customerSession->getCustomer()->getYourAttribute()){
           return parent::toHtml();
      }
      return '';
   }
}

I wanted to hide the two links named "Agent Create" and "Agent View" id the user is not of a particular group.

This is an implementaion i was trying , but i didnt get any result.
Please help !


texts: How can I add icons in Magento Homepage header?


texts:
I am getting all status which I have created from admin by the following code in my configuration section now I want to show just complete and processing state status

foreach($this->salesOrderConfigFactory->create()->getStatuses() as $status => $statusLabel)
{
    $returnArray[] = array('value' => $status, 'label' => __($statusLabel));
}
return $returnArray;


texts: Magento 2.2.5 : Module manager is not working in admin panel

texts:
I upgrade to Magento 2.2.2 to 2.2.5.

Now, in my admin panel When I open Module Manager, Then it was display error in console and grid not display.

Error :

  GET : https://www.example.com/mage2.2.5/setup/index.php/moduleGrid/modules 500(Internal Server Error) angular.js : 7715

How, can I remove this error and display grid?


texts: Attributes - Where Are Advanced Settings Stored

texts: I can't seem to find where additional attribute information like the value for is_searchable or apply_to stored in the database? I can't find this data anywhere in the eav_* tables.


texts: how can we edit (change products color/size ) on an order with status "processing"?

texts:
When an order get status "processing" there is no "edit" button in backend.

How can we edit an order with status "processing". ex. change color/size on products. (before the invoice is created) ?


texts:
I have configured all things by going System->Webservices menu, submenus that start with REST.And then I test in myDomainname/api/rest/, but it shows a 404 error like

  "Request does not match any route".

It is shown the guide tutorial in http://www.magentocommerce.com/api/rest/introduction.html  here, not fully. I need to show all orders details,details. But I can't understand what is next procedure after configuring/setting up . I need total step by step procedure after configuring in System->Webservice->REST.

Under configuration i created a rule as assigend user to that


texts: Magento2 - programatically add to cart multiple configurable products

texts:
I am facing some problems when trying to add to cart multiple configurable products in 1 single request

We have tuned product list page, to add the required form values for this kind of request (configurable child options, etc...) and this values are sent to a custom controller action

This is the controller code

<?php
namespace Vendor\Module\Controller\Add;

class Cart extends \Magento\Framework\App\Action\Action
{
    protected $_cart;
    protected $productRepository;
    protected $formKeyValidator;

    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Checkout\Model\Cart $cart,
        \Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
        \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator
    ) {

        $this->_cart = $cart;
        $this->productRepository = $productRepository;
        $this->_formKeyValidator = $formKeyValidator;

        return parent::__construct($context);
    }

    public function execute()
    {
        if (!$this->_formKeyValidator->validate($this->getRequest())) {
            return $this->resultRedirectFactory->create()->setPath('*/*/');
        }

        $qtys       = $this->getRequest()->getParam('qty');
        $childIds   = $this->getRequest()->getParam('child_ids');

        $add = array();
        foreach ($qtys as $parentId => $array) {
            if (is_array($array)) {
                foreach ($array as $attributeId => $child) {
                    foreach ($child as $childId => $value) {
                        if ($value != 0) {
                            $add[$parentId][$attributeId][$childId] = $value;
                        }
                    }
                }
            } else {
                // simple products?
                // @todo
            }
        }

        foreach ($add as $productId => $data) {
            $_product = $this->productRepository->getById($productId);

            foreach ($data as $attributeId => $child) {
                foreach ($child as $childId => $qty) {
                    $options = array(
                        $attributeId => $childId,
                    );

                    $params = array(
                        'form_key' => $this->getRequest()->getParam('form_key'),
                        'product' => $productId,
                        'super_attribute' => $options,
                        'qty' => $qty,
                        'selected_configurable_option' => $childIds[$productId][$attributeId][$childId],
                    );
                    $this->_cart->addProduct($_product, $params);
                }
            }
        }
        $this->_cart->save();
        return $this->resultRedirectFactory->create()->setPath('checkout/cart');
    }
}

This are the results I am getting

when adding different children of same configurable product only the first is being added to cart (with qtys of others being added to that first child)
when adding different configurable products (with any children) product prices are displayed correctly only in the first configurable product... the others show price 0€

Assuming the data in both $qtys & $childIds arrays are correct (I have validated them against data sent from a configurable product view add to cart request, and they seem ok), can you lead me to the error in the controller code, or any missing code required to be added?


texts: Configurable Product Price correct on Product Page, but wrong in Checkout

texts:
When configuring a product on the product page, the price works out whatever the price of the product is plus the combined amount of options added which is correct.

but when I add the product to the checkout, it will show the wrong price. I am trying to fix the issue , but i am not getting how to fix it.

The price in the checkout is working out:

item + option[1]
item + option[2]
item + option[3] +
---------------------------
£1,725.99

instead of:

item
option[1]
option[2]
option[3]+
---------------------------
£927.99

the site is using onestepcheckout and also simple-product.
I don't think these are the issues as when I turn onestepcheckout off, i still have the same problem.

I hope this makes sence, thanks in advance!


texts: Magento2 Plugins not working - before/after

texts:
I have no issues when doing an around plugin - but for a before and after plugin, I always get errors:

For instance, I want to print out something before or after a REST call is made:

class Rest
{

 /**
  * Handle REST request
  *
  * @param \Magento\Framework\App\RequestInterface|\Magento\Framework\Webapi\Rest\Request $request
  */
   public function beforeDispatch(\Magento\Framework\App\RequestInterface $request)
   {
       var_dump($request->getContent());
   }

}

<type name="Magento\Webapi\Controller\Rest">
    <plugin name="restPlugin" type="MyCompany\MyMod\Plugin\Rest" sortOrder="1" disabled="false"/>
</type>

I get the following.

'Uncaught TypeError: Argument 1 passed to MyCompany\MyMod\Plugin\Rest::beforeDispatch() must implement interface Magento\Framework\App\RequestInterface, instance of Magento\Webapi\Controller\Rest\Interceptor given

It's the same if I do after - I've tried to cast the input variable differently, but doesn't work.


texts: what was the correct way to update file for admin html module-backend?

texts:
i want to change in file location :

  /var/www/html/vendor/magento/module-backend/view/adminhtml/templates/media/Uploader.php

but its core file. I'm changing MAX_IMAGE_HEIGHT and MAX_IMAGE_WIDTH in this php file. where to update this file, the correct way .

i thinks i should in /var/www/html/app/code/Ves/Setup
there are some folders
block
controller
view
etc ..

is there something i need to to do?
please guide me.


texts: How to get manufacturer attribute value on Checkout success page?

texts:
I am trying to get the attribute values for products in an order and show them on the checkout success page.

So far I have been able to get SKU, NAME, but MANUFACTURER won't show any value...

Here is the code I am using to get the items from the checkout session:

<?php //
    $products = array();
    $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
    $_order = Mage::getSingleton('sales/order')->load($lastOrderId);

    /* @var $item Mage_Sales_Model_Order */
    foreach ($_order->getAllVisibleItems()  as $item) {
        $info['sku'] = trim($item->getSku());
        $info['qty'] = $item->getQtyOrdered();
        $info['name'] = $item->getName();
        $info['manufacturer'] = $item->getManufacturer();

        $products[] = $info;

    }

    $config['productInfos'] = $products;
?>

And to echo the values:

                            <?php foreach ($config['productInfos'] as $product): ?>
                                <?php echo trim(stripslashes(htmlentities($product['manufacturer']))); ?>
                                <?php echo trim(stripslashes(htmlentities($product['name']))); ?>,
                                <?php echo trim(stripslashes(htmlentities($product['sku']))); ?>,
                            <?php endforeach; ?>

Can anyone see what is wrong with my code?


texts: subcategory listing in sidebar of category page?

texts:
I need to show subcategories in sidebar for currently opened category page.

e.g

CMS
  wordpress
    Art
    Auction
  joomla
  drupal

if i am on cms page it shows wordpress, joomla ,drupal in sidebar.
if i am on wordpress it shows art and auction.
but if i am on art page , left side is blank..in that case i want it to show
Wordpress (its parent)
and its subcategories.

Please suggest

EDIT

This is the code.

there is hierarchy of category, but for that last categoy in this case 'art'
has no subcategories in it.
So the sidebar comes out to be blank.

<?php

$category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
$categories = $category->getCollection()
        ->addAttributeToSelect(array('name', 'thumbnail'))
        ->addAttributeToFilter('is_active', 1)
        ->addIdFilter($category->getChildren())
 ?>

    <?php echo $category->getName() ?>

    <?php foreach ($categories as $category): ?>

            <a href="<?php echo $category->getUrl() ?>">
                <?php echo $category->getName() ?>
               <?php $collection = Mage::getModel('catalog/product')->getCollection()->addCategoryFilter($category);

echo "(".count($collection).")"; ?>

    <?php endforeach; ?>

on art category page ,i want if it has no subcategories than show its parent with its sub in sidebar.


texts:
Installed a module on Magento 2 website, after running a setup:upgrade, reindex and cache. Then I run a setup:di:compile, but I received an error.

  Class Magento\CatalogInventory\Model\StockRegistryStorage does not
  exist

I have done a chmod 777 var

Also tried

rm -Rf ../var/cache/
rm -Rf ../var/page_cache/
rm -Rf ../var/generation/
rm -Rf ../var/di/

Any ideas how I can solve the issue?  I am using Magento ver. 2.0.13

Thanks


texts:
When i try to access these url  localhost/magento2/setup

i get

Forbidden

You don't have permission to access /magento2/setup on this server.
Apache/2.4.18 (Ubuntu) Server at localhost Port 80

i added this

<Directory /var/www/html/magento2>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

to the

sudo gedit /etc/apache2/apache2.conf

this is diirectory

sudo ls /var/www/html/magento2/
app      COPYING.txt          LICENSE_AFL.txt      pub
bin      dev              LICENSE.txt      setup
CHANGELOG.md     Gruntfile.js.sample  nginx.conf.sample    update
composer.json    index.php        package.json.sample  var
composer.lock    ISSUE_TEMPLATE.md    php.ini.sample       vendor
CONTRIBUTING.md  lib              phpserver

i tried a lot of things

this is php

php -v
PHP 7.0.10-2+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.10-2+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies

this is mysql

root@vegan:/var/www/html/magento2# mysql -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 465
Server version: 5.7.13-0ubuntu0.16.04.2 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

this is apache2

root@vegan:/var/www/html/magento2# apache2 -v
Server version: Apache/2.4.18 (Ubuntu)
Server built:   2016-07-14T12:32:26
root@vegan:/var/www/html/magento2#

there seems no errors with those.

when i go to

http://localhost/magento2/setup

i got error.

i changed to

<Directory /var/www/html/magento2>
    Options Indexes FollowSymLinks
    AllowOverride all
    Require all granted
</Directory>

but nothing changed, extra line added to the error.

i also changed permissions described here

https://stackoverflow.com/a/18950561/6690056

and here

Make files and directories writable:

To make files and directories writable so you can update components and upgrade the Magento software:

Log in to your Magento server.
Change to your Magento installation directory.
Enter the following commands:

chmod -R u+w .

but now i get only pag with php code despite localhost shows true page:

for http://localhost/magento2/setup/

<?php
/**
 * Copyright Â© 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

if (PHP_SAPI == 'cli') {
    echo "You cannot run this from the command line." . PHP_EOL .
        "Run \"php bin/magento\" instead." . PHP_EOL;
    exit(1);
}
try {
    require __DIR__ . '/../app/bootstrap.php';
} catch (\Exception $e) {
    echo <<getMessage()}

HTML;
    exit(1);
}

// For Setup Wizard we are using our customized error handler
$handler = new \Magento\Framework\App\ErrorHandler();
set_error_handler([$handler, 'handler']);

\Zend\Mvc\Application::init(require __DIR__ . '/config/application.config.php')->run();

what can be reason?


texts: how to show custom order attribute in sales order view screen

texts:
I have created custom order attribute using following script.I want to show in sales order view screen below order status.
and also if order is in hold only i want to show this attribute.

<?php
$installer = new Mage_Sales_Model_Resource_Setup('core_setup');
$attribute  = array(
'type'          => 'int',
'label'         => 'Is Notified',
'default'       => 0,
'visible'       => true,
'required'      => false,
'user_defined'  => true,
'comparable'    => false );

$installer->addAttribute('order', 'is_notified', $attribute);


texts: Is it possible to manipulate the default Store View programmatically?

texts:
I recently tried to update some product-information on the default storeView (id 0). Instead of applying the changes to the default store, it instead applied them to the product in the next higher increment of storeIds.
I then tried to get all available storeIds for the product and the default store was not listed. Is it not possible to make changes to the default storeView programmatically?


texts: Magento 2: Add a mass action block item for a UI Component grid

texts:
I am trying to add a mass action item to the product grid mass action block using an observer.

Here is what I am doing but it does not seem to be working, I feel like I am missing something

app/code/DigitalPianism/ProductExport/etc/module.xml

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="DigitalPianism_ProductExport" setup_version="0.0.1" />
</config>

app/code/DigitalPianism/ProductExport/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'DigitalPianism_ProductExport',
    __DIR__
);

app/code/DigitalPianism/ProductExport/etc/adminhtml/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="adminhtml_catalog_product_grid_prepare_massaction">
        <observer name="digitalpianism_productexport_add" instance="DigitalPianism\ProductExport\Observer\AddMassExportAction" />
    </event>
</config>

app/code/DigitalPianism/ProductExport/Observer/AddMassExportAction.php

<?php
namespace DigitalPianism\ProductExport\Observer;

use Magento\Framework\Event\ObserverInterface;

class AddMassExportAction extends ObserverInterface
{

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $block = $observer->getEvent()->getBlock();

        $block->getMassactionBlock()->addItem(
            'productexport',
            [
                'label' => __('Export to CSV'),
                'url' => $block->getUrl('productExport/productexport/exportCsv')
            ]
        );
    }
}

Thanks.


texts: Magento checkout/onepage/ is coming blank after login ver 1.9.3.8

texts:
On the website sellerstreets.com when i am checking out after login it is showing a blank page.

I tried some solutions but none is working. Please help me out its quite urgent as the website is live.


texts: Remove  tags from shipping address fields on the checkout page in Magento 2.2.2

texts:
I am trying to remove all the <label> tags from a shipping address form on the checkout page.

Here is the answer to hide those labels using CSS.

I am trying to move those labels below the input fields.

Any guidance would be appreciated.


texts: Magento 2 Add custom class before "main.content" excluding Home Page

texts:
I am looking for a solution to add a custom class before "main.content" for all pages remaining home page. Currently, I am doing below code

<referenceContainer name="page.wrapper">
           <container name="your.custom.name" as="your-custom" label="Your Label Name" htmlTag="div" htmlClass="custom_class" htmlId="your-id" before="page-footer"/>
  </referenceContainer>
  <move element="main.content" destination="your.custom.name"/>

in default.xml.

but this code adding "custom_class" class for all pages. I want to exclude from the home page. Please suggest if anyone has an idea.


texts:
For Image optimisation, I want't to get Product Image Size. (Either in KB or MB etc.)

Ex: 6 KB, 6KB,5KB etc.
I am using following code on root path.
<?php

error_reporting(1);
ini_set('max_execution_time', 0);
use \Magento\Framework\App\Bootstrap;

require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$instance = \Magento\Framework\App\ObjectManager::getInstance();
$state = $objectManager->get('\Magento\Framework\App\State');
$state->setAreaCode('frontend');
$product_collections = $instance ->get('\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
$collections = $product_collections->create();
$i = 0;
foreach ($collections as $product) {

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();

    $productRepository = $objectManager->get('\Magento\Catalog\Model\ProductRepository');
    $productObj = $productRepository->get($product->getSku());

    echo "".$productObj->getName()."";
        echo "
";

        $i++;
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $directory = $objectManager->get('\Magento\Framework\Filesystem\DirectoryList');
    $mediaPath = $directory->getPath('media');

    $product_id = $productObj->getId();
    $product = $objectManager->create('Magento\Catalog\Model\Product')->load($product_id);

    $galleryReadHandler = $objectManager->get('Magento\Catalog\Model\Product\Gallery\ReadHandler');
    $galleryReadHandler->execute($product);
    $images = $product->getMediaGalleryImages();

        foreach($images as $image){
            echo "
";print_r($image);echo "
";
         $temp = $mediaPath."/catalog/product".$image->getFile();
         //echo "
"; print_r($temp); echo "
";
         echo $temp;
         echo "
";
        }
}
echo "Total Products: ".$i;


texts: Malicious Files - Backed Up To Local Machine Dangerous?

texts: This may seem like a silly question, but our virtual dedicated server has been spammed (outgoing mail spam) and it appears that our server may have been compromised because the latest Magento updates haven't been done (bad, I know). I want to get Magento updates, but first I really wanted to create a backup of the files on our local server (i.e. computer) so that we have them to reference / fall back on as needed. My concern is that am I putting my computer at harm being that there are malicious files in there causing the spam? The last thing I want is a virus on the computer too. Thanks!


texts:
I'm trying to deploy my updated website. But when I move my files over, my website is no longer in "Secured" due to mixed content.

The mixed content is the website trying to call images from my development server

instead of saying: https://www.website.com/image1

It brings up /IP ADDRESS of dev server/image1

Since my dev server is not for the public, it does not have SSL on it. But I'm not sure why its bringing up files from my development server now that i'm on the production server.

Any suggestions?


texts: How to load product from multiple category in magento

texts:
I need to get a collection in magento by multiple categories but I am not getting any product when I add more categories.

$products = Mage::getModel('catalog/category')->load(7,8)
                ->getProductCollection()
                ->addAttributeToSelect('*') // add all attributes - optional
                ->addAttributeToFilter('status', 1) // enabled
                ->addAttributeToFilter('visibility', 4) //visibility in catalog,search
                ->setOrder('price', 'ASC'); //sets the order by price
         $this->setProductCollection($products);
        return $products;


texts: Save all shipping quotes into a order information

texts:
I want to save all shipping quotes with their shipping methods names and prices and put it with order information in magento 2. It will be visible only to admins, inside order informations. I'm using magento 2.3.5. How can I do this?
Thank you.


texts: How to send an email programmatically in Magento 2?

texts: How to send an email programmatically in Magento 2 instead of php mail() function?


texts: How to limit the number of products on the site that loads for mobile users?

texts: We have the Porto theme installed on Magento 1.9.1.0. It works well on the desktop version but loads very slow on a smart phone (even though it's a 100% responsive mobile friendly theme) because we have something like 40 products on the front page. What is the easiest way to keep the same responsive theme but limit the number of products that show up on the front page of mobile devices? We want to keep the same domain such as www.myDomain.com (same as the desktop verion) because of SEO.


texts: How can I load a custom CSS File both in adminpanel and frontend?

texts:
Is there a way to load the same css file in admin and frontend? I do not want to create 2 files with the same content and include them in adminthml and frontend folders.

I know How to include a js file in admin and frontend. I just put it in js folder and loaded from xml:
For instance:

<action method="addItem"><type>js</type><name>datepicker/custom_datepicker.js</name></action>

How can I do the same thing with a CSS File ?


texts:
My store currently uses Magento CE 1.5.0.1 and it works well on server with PHP 5.4.45. Now the server will be upgraded to PHP 5.5. Will my store (Magento CE 1.5.0.1) supports PHP 5.5?

Appreciate any input!


texts: Virtual host for magento2 under lampp service for Ubuntu

texts:
I  tried to set virtual host for Magento2(2.2.5) Project in Ubuntu system under Lampp service.

I added this piece of code under opt/lampp/etc/extra/httpd-vhosts.conf

  <VirtualHost *.:80>
  ServerName magento2.local
  DocumentRoot "/opt/lampp/htdocs/Magento2/"
  DirectoryIndex index.php
  <Directory "/opt/lampp/htdocs/Magento2/">
        Options All
        AllowOverride All
        Require all granted
  </Directory>
  </VirtualHost>

And added that under /etc/hosts

127.0.0.1     magento2.local

Uncommented below piece of line under nano /opt/lampp/etc/httpd.conf

Include etc/extra/httpd-vhosts.conf

Restarted the service

/opt/lampp/lampp restart

After this when I try to hit magento2.local it again redirects with the normal URL localhost/Magento2

Nothing works.

Welcome for suggestions.

Thanks in advance.


texts:
we have a general module which implements some widget functionality and adds basic templates to a shop, which are defined in the widget.xml like this:

<some_module>
    <name>my name</name>
    <parameters>
        <template translate="label description">
            <visible>1</visible>
            Block template
            <description>Template to render the block</description>
            <type>select</type>
            <value>cms/widget/static_block/default.phtml</value>
            <values>
                <default translate="label">
                    <value>cms/widget/static_block/default.phtml</value>
                    CMS Static Block Default Template
                </default>
                <table_2columns translate="label">
                    <value>foobar/module/static_block/2columns.phtml</value>
                    2 Columns Table
                </table_2columns>
            </values>
            <sort_order>10</sort_order>
        </template>

We use that basic configuration a lot, but now want to remove one of the entires in  in a child extension, which are usually just used to add more project specific templates, but should this time also remove one of the defaults. Unfortunately there's nothing like a remove tag for values entries. Also setting the value or label to an empty string does not work. :(

I'm currently looking for an event to extend the renderer and removing the values in there, but that feels quite dirty and it would be a lot nicer to do that actually in the widget.xml of the extending module. Is there a way to do that without changing the code of the parent/general module?


texts:
I'm trying to loop through a lot of order ids and fetching the order data but performing a clearInstance() on an order model variable doesn't seem to clear the data and I keep getting the same data. Has anyone else experienced this? For now I'm having to just use this which uses up way too much memory.

Mage::getModel('sales/order')->load($order['order_id'])


texts: How To Download Magento 2.2.0 RC Setup using Composer?

texts:
I know how to install Magento 2 using composer. Magento lattest release of beta version Magento 2.2.0 - Dev.I don't know how to download or Installation Using Composer. I try to run direct

  "composer create-project --repository-url=https://repo.magento.com/
  magento/project-community-edition=2.2.0 ."

but it's not working.Anyone have a command?

Magento 2.2.0 Git Release Path ::

https://github.com/magento/magento2/releases


texts:
Is there a core class (preferably a framework class) in Magento 2 that can be used to generate random strings? Length of the string is not important.
I don't want to reinvent the wheel and write my own.


texts: Faced an error during upgrading Magento version from 2.3.5 to 2.4.0

texts:
I'm going to upgrade Magento version 2.3.5 to  2.4.0 and getting below error.
Please suggest if anyone has faced the same error.

Thanks


texts:
Following are the 4 conditions.

Single block and multiple templates - I think this is possible and we use it frequently while customizing Magento.
Multiple blocks and single template - Never seen this one though.

Also not sure about below conditions too.

Multiple block instances and single template
Multiple block instances and multiple templates

Can anyone explain the above conditions and deduct whether these are true or not?


texts:
Recently we have received the POTENTIAL PROCESSING IMPACT - Action Required: Update your Braintree SDK version by May 1 notification from Braintree. And I tried to upgrade the braintree_php from 3.7.0 to 3.8.0 but throwing error. For this, I have run the below commands.

composer require braintree/braintree_php:3.8.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - magento/magento2-base 2.1.4 requires braintree/braintree_php 3.7.0 -> satisfiable by braintree/braintree_php[3.7.0] but these conflict with your requirements or minimum-stability.
    - magento/magento2-base 2.1.4 requires braintree/braintree_php 3.7.0 -> satisfiable by braintree/braintree_php[3.7.0] but these conflict with your requirements or minimum-stability.
    - magento/magento2-base 2.1.4 requires braintree/braintree_php 3.7.0 -> satisfiable by braintree/braintree_php[3.7.0] but these conflict with your requirements or minimum-stability.
    - Installation request for magento/magento2-base (locked at 2.1.4) -> satisfiable by magento/magento2-base[2.1.4].

Installation failed, reverting ./composer.json to its original content.

We are using Magento V2.1.4.

Please suggest us to upgrade the braintree_php to save from security risk.


texts: What is the best event to be fired when adding and deleting a free product in Magento 2?

texts: I want to add product Y to cart with product X and want to delete product Y when product X is deleted.(both should be worked automatically). For this purpose what will be the best event to be fired??


texts:
Developing a simple custom module, and the hardest part is getting the template to load in the admin.  I'm sure I'm missing something simple (but important).

The template will not load.  I believe all of the layout / config is loading properly.

The module controller is firing (proven via var_dump), and it appears that the layout is loading.

A var_dump(Mage::getSingleton('core/layout')->getUpdate()->getHandles()); produces one of the handles that seems correct: adminhtml_mymodule_index.

In app/code/local/mycompany/mymodule/etc/config.xml, I've got this bit (among others):

<adminhtml>
    <layout>
        <updates>
            <mycompany>
                <file>mymodule.xml</file>
            </mycompany>
        </updates>
    </layout>
</adminhtml>

In app/design/adminhtml/default/default/layout/mymodule.xml, I've got this:

<layout>
    <mycompany_adminhtml_mymodule_index>
        <update handle="mycompany_mymodule_index" />
        <reference name="content">
            <block type="adminhtml/template" name="mymodule" template="mymodule/index.phtml" />
        </reference>
    </mycompany_adminhtml_mymodule_index>
</layout>

The template is located at
app/design/adminhtml/default/default/template/mymodule/index.phtml
and contains some basic text just be able to prove if it loads.

I've got cache completely disabled (development environment), and have Magento in developer mode with no errors being thrown.

What am I missing?  I've been able to prove that the layout file (mymodule.xml) is loading, but for some reason I cannot get the template file to load.


texts: Adding custom generated coupon code from observer to New Account email template

texts:
I have written a custom observer during customer save after event to generate unique coupon codes and append in welcome email during that is sent during Customer Registration.

The coupon code functionality is working fine. Using send() I am trying to pass the custom variables I stored in an array. But I am unable to add it in the template.

Please find below my code snippets.

Observer.php

<?php

class XYZ_Promocode_Model_Observer {
    public function customerSaveAfter(Varien_Event_Observer $o) {
        $customerData = $o -> getCustomer() -> getData();

        if (!$o -> getCustomer() -> getOrigData()) {
            $modelcollection = Mage::getModel('salesrule/rule') -> getCollection();
            $newCollection = array();
            $newCollection = $modelcollection -> getData();

            $ruleName = $newCollection[0]['name'];
            $rule_id = $newCollection[0]['rule_id'];

            if ($rule_id == 1 && $ruleName == "RegisteredUserPromocode") {
                $rule = Mage::getModel('salesrule/rule') -> load(1);

                $generator = Mage::getModel('salesrule/coupon_massgenerator');

                $parameters = array('count' => 1, 'format' => 'alphanumeric', 'dash_every_x_characters' => 4, 'prefix' => 'ABCD-EFGH-', 'suffix' => '-WXYZ', 'length' => 8);

                if (!empty($parameters['format'])) {
                    switch( strtolower($parameters['format']) ) {
                        case 'alphanumeric' :
                        case 'alphanum' :
                            $generator -> setFormat(Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHANUMERIC);
                            break;
                        case 'alphabetical' :
                        case 'alpha' :
                            $generator -> setFormat(Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHABETICAL);
                            break;
                        case 'numeric' :
                        case 'num' :
                            $generator -> setFormat(Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_NUMERIC);
                            break;
                    }
                }

                $generator -> setDash(!empty($parameters['dash_every_x_characters']) ? (int)$parameters['dash_every_x_characters'] : 0);
                $generator -> setLength(!empty($parameters['length']) ? (int)$parameters['length'] : 6);
                $generator -> setPrefix(!empty($parameters['prefix']) ? $parameters['prefix'] : '');
                $generator -> setSuffix(!empty($parameters['suffix']) ? $parameters['suffix'] : '');

                $rule -> setCouponCodeGenerator($generator);
                $rule -> setCouponType(Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO);

                $count = !empty($parameters['count']) ? (int)$parameters['count'] : 1;
                $codes = array();
                for ($i = 0; $i < $count; $i++) {
                    $coupon = $rule -> acquireCoupon();
                    $coupon -> setType(Mage_SalesRule_Helper_Coupon::COUPON_TYPE_SPECIFIC_AUTOGENERATED) -> save();

                    $code = $coupon -> getCode();
                }

                $emailTemplate = Mage::getModel('core/email_template') -> loadDefault('coupon_new_customer');

                $emailTemplateVariables = array();

                $emailTemplateVariables['username'] = $customerData['firstname'] . ' ' . $customerData['lastname'];
                $emailTemplateVariables['customer_email'] = $customerData['email'];
                $emailTemplateVariables['promo_code'] = $code;

                $result = $emailTemplate -> send($customerData['email'], $customerData['firstname'] . ' ' . $customerData['lastname'], $emailTemplateVariables);
            }
        }
    }

}

Ways tried to retrieve in email template:

1. {{var promo_code}}

2. {{var emailTemplateVariables.promo_code}}


texts: does Magento support galera cluster for Mysql?

texts: I have read many blogs related to this argument but cannot find out the final answer . Is it possible to adopt galera cluster for Mysql as database solution for Magento ? Is is enough to add the missing primary keys ,move Myisam table to Innodb and remove the full text index ?


texts: Magento 2 command line utility saying "Access denied for user"

texts:
My magento 2 installation is working fine, but when I go to terminal and try to use any command, for example image resize, it is giving me following

[Zend_Db_Adapter_Exception]
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

As noted, front end is working fine.


texts: When to dispatch events in a custom module?

texts:
This is a question regarding both Magento 1 and Magento 2.

I understand that, as a good practice, 3rd party modules developers are encouraged to dispatch events in their custom module to make it easier to work with other modules.

I would like to know:

where should a developer dispatch events in a custom module ?
is there any recommended spot to dispatch events? E.g. Controllers, models, blocks, helpers, observers ?
how dispatching events affect performance ?


texts: Magento 2 : By Default is There Page That Groups All Featured Products

texts:
I need to create featured page / category where all featured products are grouped.

By default I create an hidden (from the menu) category and I add products both to featured category and with featured flag.

I was wondering if there is nicer way to do this. Is there already a page, by default, that includes all featured products? Or is there a way to automate adding a product to a category if it gets featured?

Any other suggestions are welcome.


texts: Add FIlter to Grid under category section products in category tab

texts:
I am using Magento 2.3.4 EE. Anyone have any idea how can I add a filter under category section and 'products in category' tab admin.

If you guys have any Idea please share.
Any help will be appreciated.
Thanks


texts: Magento 2.2: How to remove add_to_wishlist button from, and add SKU view in, recently viewed products widget in module

texts:
I want a extra tab on product page with 4 previously viewed products. Besides that I want to remove "add_to_cart,add_to_compare,add_to_wishlist" buttons and add SKU attribute to recently viewed products in my module.

Probably not the right approach, but I do get 4 recently viewed Products. I have this code now:

  Knot\PreviousTab\registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Knot_PreviousTabPDP',
__DIR__
);

  Knot\PreviousTabPDP\etc\module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Knot_PreviousTabPDP" setup_version="1.0.0">
    </module>
</config>

  Knot/PreviousTabPDP/view/frontend/layout/catalog_product_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="product.info.details">
        <block class="Knot\PreviousTabPDP\Block\PreviousProductsTab" name="previous_products.tab" as="previous_products_tab" template="Knot_PreviousTabPDP::previous_products.phtml" group="detailed_info">
            <arguments>
                <argument name="title" translate="true" xsi:type="string">Previous Products</argument>
            </arguments>
        </block>
    </referenceBlock>
</body>

  Knot/PreviousTabPDP/view/frontend/templates/previous_products.phtml

<?php
echo $this->getLayout()
->createBlock("Magento\Reports\Block\Product\Widget\Viewed")
->setDisplayType("recently.view.products")
->setPageSize("4")
->setTemplate("widget/viewed/content/viewed_grid.phtml")->toHtml()
; ?>

and a empty

  Knot/PreviousTabPDP/Block/PreviousProductsTab.php

<?php

namespace Knot\PreviousTabPDP\Block;

use Magento\Catalog\Model\Product;

class PreviousProductsTab extends \Magento\Framework\View\Element\Template
{

}


texts: Looking for a way to change change a navigation block in a Category Page

texts:
I want to be able to change our hallwines.com/shop page layout when going to a category page that will be say, http://www.hallwines.com/shop-wine-gifts so that I can have a custom Navigation side bar that will only show on this category page. I have a block setup to replace it in the the "Custom Layout" just not clear on how to call it and the code to stop the regular Shop Side bar from showing? Any help would be greatly appreciated, perhaps even a bottle of wine in it for you, and we make really good wine!

thanks much

Mbuckley@hallwines.com


texts:
I have written code to change the sorting logic in Toolbar.php using report_viewed_product_aggregated_monthly. It is working fine, actually the tables

  report_viewed_product_aggregated_monthly

and

  report_viewed_product_aggregated_yearly

not updated.

But the table

  report_viewed_product_aggregated_daily

updates daily.

When I use report_viewed_product_aggregated_daily table for sorting, the query takes much time to load.

Toolbar.php

$this->_collection->getSelect()
            ->joinLeft(
                array('sfoi' => $this->_collection->getResource()->getTable('sales/order_item')),
                'e.entity_id = sfoi.product_id',
                array('qty_ordered' => new Zend_Db_Expr('SUM(sfoi.qty_ordered)'))
                )
            ->joinLeft(
                array('si' => $this->_collection->getResource()->getTable('cataloginventory_stock_item')),
                'si.product_id = e.entity_id',
                array('instock' => 'si.is_in_stock')
                 )
            ->joinLeft(
                array('search' => $this->_collection->getResource()->getTable('catalogsearch_fulltext')),
                'search.product_id = e.entity_id',
                array('search_weight' => 'search.searchindex_weight')
                )

            ->joinLeft(
                array('_table_views' => $this->_collection->getResource()->getTable('report_viewed_product_aggregated_daily')),
                '_table_views.product_id = e.entity_id',
                array('views' => new Zend_Db_Expr('SUM(_table_views.views_num)'))
                )
            ->group('e.entity_id')
            ->order(array('instock DESC','created_at DESC', 'minimal_price ASC','qty_ordered DESC', 'search_weight DESC','views DESC'));
            $collection->printLogQuery(true);

Can anyone suggest me, how to make debug, why those tables are not updated regularly.


texts: Magento 2 how to move default.html from base folder to custom theme folder

texts:
I have created Magento_Catalog folder in custom theme and moved template files there which are working fine. Now i want to move the files from module-catalog base folder to custom theme Magento_Catalog folder.

Want to move /vendor/magento/module-catalog/view/base/templates/product/price/amount folder.

How can i do that ?


texts: How to add a product to a collection by ID

texts: Lets say I have an empty collection and a list of productIDs. I want to populate the collection with products specified by the IDs in the list. How would I do this?


texts:
I have this method

public function createParticipantAction(){
  ...
  $checkData = $this->validateData($data);
  if($checkData==true){
     $this->_redirect('course/participant/create');
     exit();
  }
  ...
}

public function validateData($data){
if($data){
    $session = Mage::getSingleton('core/session');
    $validateData = Mage::getModel('course/participant');
    $validateData->addData($data);
    $name = $validateData->getName();
    if($name==''){
        $session->addError('Name Error');
    }
    return true;
 }
  return false;

}

When calling $this->validateData($data), if the name is null, it will exit and redirect to the registration page. But right now it doesn't work.

Help me, please!


texts: Creating a module with exact replica of the Manage Attributes

texts:
I'm planning to create a manufacturer module wherein I can add Manufacturer and choose products that they manufacture from the Products added (Product List) in the store. And display Manufacturer on frontend listing the Products they manufacture from my Store.
But first and foremost I want to know how to clone the "Manage Attributes" of Magento for this will be my starting ground. Can anyone here guide, help or walk me through on it? Or someone can provide link on how to achieve such?

Looking forward to hear from the experts.


texts: Which data to fill to show order in grid order row

texts:
I get some data and save it to the sales_flat_order and sales_flat_order_address .
My issue is that I can't see my order created on the Magento grid order.
Which data I have to fill or add to see my order into the grid?

This is the attribute I fill in both tables.

foreach($array as $value){
    $array = array(
        'status' => $value['status'],
        'base_grand_total' => $value['price'],
        'grand_total' => $value['price'],
        'increment_id' => $value['number'],
        'base_currency_code' => 'MXN',
        'customer_email' => $value['email'],
        'customer_firstname' => $value['name'],
        'customer_lastname' => $value['apellido'],
        'global_currency_code' => 'MXN',
        'order_currency_code' => 'MXN',
        'store_name' => 'linio marketplace',
        'created_at' => $value['created'],
        'updated_at' => $value['created'],
        'total_item_count' => $value['item']
    );

    $modele = Mage::getModel('thorleif/order')->setData($array);
    $modele->save();

    $id = $modele->getId();
    $array = array(
        'parent_id' => $id,
        'region' => $value['region'],
        'postcode' => $value['zip'],
        'street' => $value['address'].'.'.$value['country'],
        'city' => $value['city'],
        'email' => $value['email'],
        'telephone' => $value['tel'],
        'firstname' => $value['name'],
        'lastname' => $value['apellido'],
        'address_type' => 'shipping'
    );

    $modele = Mage::getModel('thorleif/address')->setData($array);
    $modele->save();
    $id = $modele->getId();
}


texts: M2 Add fields to custom payment method [ship to multiple address]

texts:
I have created a custom payment method, which is working fine, but when i select ship to different address, than payment method was not appearing.
I added "allow_multiple_address" to 1.
Now payment method label is visible but the custom input field and custom button is missing.
It is also creating a invoice automatically


texts:
I am using magento v1.7.0.2, and also setup fedex sandbox mode.
It is showing error while creating shipping label " An error occurred while creating shipping label."

When I have reviewed exception log it shows below error:

SoapFault exception: [soapenv:Server] Schema validation failed for request. in  app/code/core/Mage/Usa/Model/Shipping/Carrier/Fedex.php:1475

We have also implement patch from here, but still it is showing same error.

Please help me to resolve this error.


texts: SUPEE-5344 Patching problems magento 1.7.x.x

texts:
I have uploaded the patch to my root Magento folder but I get the following error

1 out of 1 hunk FAILED -- saving rejects to file lib/Varien/Db/Adapter/Pdo/Mysql.php.rej

I see this question has been asked and I tried to upload the patched file as described on:

http://magentary.com/kb/apply-supee-5344-and-supee-1533-without-ssh/

but this causes my site to crash.


texts: admin field select box default value from database while edit

texts:
I have a problem while editing my custom admin module.

Custom module working fine but while editing I have to a display select box value as selected from database records,

I have two values and in database the datatype is enumeration. the values are

1=> image
2=> video

While editing I have to display image or video based on the database value. but I am not getting proper result here is my code.

$fieldset->addField('add_type', 'select', array(
          'label'     => Mage::helper('advertisement')->__('Media'),
          'name'      => 'add_type',
          'onchange' => 'checkSelectedItem(this.value)',
          'value'  => '',
          'values' => array(array('value'=>'0','label'=>'Select Type'),
                            array('value'=>'1','label'=>'Image'),
                            array('value'=>'2','label'=>'Video'),
                       ),
);

I have Tried this too

$recordId = Mage::registry('storeadvertisement_data')->getData();
        $selectVal = Mage::getModel('advertisement/advertisement')->load($recordId['id'])->getData('add_type');
  $fieldset->addField('add_type', 'select', array(
          'label'     => Mage::helper('advertisement')->__('Media'),
          'name'      => 'add_type',
          'onchange'  => 'checkSelectedItem(this.value)',
          'value'     => $selectVal,
          'values'    => array(array('value'=>'0','label'=>'Select Type'),
                            array('value'=>'1','label'=>'Image'),
                            array('value'=>'2','label'=>'Video'),
                       ),
);

But it did not help.


texts: how to uncheck exclude image checkbox at mass image import

texts:
I am trying to update the images of my catalog with the following CSV:

sku,image,small_image,thumbnail
aaaaaa,/TP1501054_15_1.jpg,/TP1501054_15_1.jpg,/TP1501054_15_1.jpg

I like to know how i can exclude the small_image and thubmnail. I am using default magento enterprise import for importing. I dont like to use MAGMI.


texts:
I have a product collection and my code look like this

       $collection = Mage::getResourceModel('catalog/product_collection')
        ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
        ->addAttributeToSelect('groupdeal_fineprint')
        ->addAttributeToSelect('groupdeal_highlights')
        ->addStoreFilter()
        ->addAttributeToFilter('entity_id', array('in' => $productIds))
        /*->addAttributeToFilter('groupdeal_status', Devinc_Groupdeals_Model_Source_Status::STATUS_RUNNING)*/
        ->joinField('groupdeals_id','groupdeals/groupdeals','groupdeals_id','product_id=entity_id',null,'left')
        ->joinField('inventory_in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id','is_in_stock>=0', 'left')
        ->joinField('position','groupdeals/groupdeals','position','product_id=entity_id',null,'left')
        ->setOrder('groupdeals_id','desc')
        ->setOrder('on_top','asc');

When i remove setOrder('on_top','asc') everything works perfect but if i place that code my products doesnt display. Thanks in advance for the help


texts: How to add a unique custom attribute for a customer?

texts:
I was able to add a custom attribute called 'Username' to the Magento Customer model.

The install-function in InstallData.php looks like this:

public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
    $this->logger->info("Username data installed.");

    /** @var CustomerSetup $customerSetup */
    $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

    $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
    $attributeSetId = $customerEntity->getDefaultAttributeSetId();

    /** @var $attributeSet AttributeSet */
    $attributeSet = $this->attributeSetFactory->create();
    $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

    $customerSetup->addAttribute(Customer::ENTITY, 'username', [
        'type' => 'varchar',
        'label' => 'Username',
        'input' => 'text',
        'required' => false,
        'visible' => true,
        'user_defined' => true,
        'unique' => true,
        'required' => true,
        'sort_order' => 1000,
        'position' => 1000,
        'system' => 0,
    ]);

    $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'username')
    ->addData([
        'attribute_set_id' => $attributeSetId,
        'attribute_group_id' => $attributeGroupId,
        'used_in_forms' => ['adminhtml_customer', 'checkout_register', 'customer_account_create', 'customer_account_edit', 'adminhtml_checkout'],
    ]);

    $attribute->save();

}

Everything works correctly, but the 'unique' => true does not work. I found out that this field is not used for customers and uniqueness must be programmed manually.

So I basically want to check the uniqueness of the attribute just before a customer is saved to the database (so just before account creation).

I found this code in app/code/Magento/Customer/Model/ResourceModel/Customer.php in _beforeSave().

    $connection = $this->getConnection();
    $bind = ['email' => $customer->getEmail()];

    $select = $connection->select()->from(
        $this->getEntityTable(),
        [$this->getEntityIdField()]
    )->where(
        'email = :email'
    );
    if ($customer->getSharingConfig()->isWebsiteScope()) {
        $bind['website_id'] = (int)$customer->getWebsiteId();
        $select->where('website_id = :website_id');
    }
    if ($customer->getId()) {
        $bind['entity_id'] = (int)$customer->getId();
        $select->where('entity_id != :entity_id');
    }

    $result = $connection->fetchOne($select, $bind);
    if ($result) {
        throw new AlreadyExistsException(
            __('A customer with the same email already exists in an associated website.')
        );
    }

It is exactly this behaviour for the email that I want to replicate for my username.

Does anyone have an idea how I do this?

Thank you!


texts: How to execute large sql query in magento?

texts:
I want to store huge content in db and my sample text is 16129 characters in length when i tried to execute this query it is showing "error:The requested URL could not be retrieved" in firefox and "no-data received" in chrome.

I use LONGTEXT as datatype for column content in DB.

I also tried to execute the query directly in phpmyadmin with same huge content.It is working correctly.

The code is shown below.

    public function _getConnection($type = 'core_write') {
            return Mage::getSingleton('core/resource')->getConnection($type);
        }

    public function testdbAction(){
            $db = $this->_getConnection();
            $current_time=now();
            $text="The European languages are members of the same family......  ...Europe uses the same vocabulary. The ";
//$text is 16129 characters in length
            $sql = "INSERT into test(`usercontent_id`,`app_id`,`module_id`,`customer_id`,`content`,`created_time`,`updated_time`,`item_id`,`index_id`,`position_id`) VALUES (NULL, 15, 9,2,'" .$text. "','" . $current_time . "','" . $current_time . "',1003,5,4)";
           //echo  $sql; exit;
            $db->query($sql);
        }

But when I tried the same in Magento,  $db->query($sql);  does not able to run the query. Kindly advice on this.


texts: Remove flat rate handling fee on orders above 1000

texts:
How can i remove flat rate handling fee if the order is above $1000 ?I cant do it with a rule, as it still shows as if some discount was applied.I need to remove the handling fee itself.

Thanks for Advance!


texts: Magento2.2 default storeview error store id not found

texts:
I have created 2 store views in magento latest 2.2

I have enabled add store view to url in settings.

But on home page it throws error store id not found.

If I add en/ at the end of url or ar/ at end it works fine.

Even the language switcher is working fine.

Only issue with home page.

How can I set the default storeview for home page ?


texts: Warning is not disappering for M2ePro module update

texts:
I am using M2ePro extension. It had version 1.3.4 and it was showing warning on admin dashboard that:

  Important: It is recommended to update to the version 1.3.5. Please
  refer to https://docs.m2epro.com/ for Installation/Upgrade
  instructions

So I updated it to version 1.4 which is latest version but still its showing above warning. I do not understand why this warning is still present when I upgraded to latest version. Please let me know from where this warning is coming and how to remove this?

Thanks


texts: Magento2 sample data install stuck at 90%

texts:
I installed Magento2 on a Nexcess server without Sample data without any issues. I then cleared the install (removed the folder completely) I dropped and recreated the database and restarted the install.

The install stalls at 90% and doesn't give me any additional feedback.

Here is the last bit of the log

Module 'Magento_Authorizenet':

Module 'Magento_OfflineShippingSampleData':
Installing data..

Module 'Magento_ConfigurableSampleData':
Installing data..


texts: How can i pass an object with it's value using DI?

texts:
I'm still new at Magento and im trying to work on something where I need to pass the product SKU from a file that has a function that retrieves the product SKU to another file with no such function, within the same Module.
In the first file Vendor_name/Module_name/Block/Catalog/Product/File_name.php, a function exists that retrieves a SKU like so:
$sourceItems = $getSourceItemsBySkuInstance->execute((string)$product->getSku());

But, in the other file, located in, Vendor_name/Module_name/Block/File_name.php, no such function exists.
So, how can I pass the $product->getSku() with its value to the 2nd file?


texts: Consumer is not authorized to access %resources ? why

texts:
hi please someone guide me how to access api in magento2 , i think i am doing some mistake , i have made a test role and assign all administrator resources to it , now when i try to hit url
(http://127.0.0.1/project/rest/V1/orders/)

it gives me following error

  Consumer is not authorized to access %resources

can anybody please describe step by step how to access api in magento2 ? i want to check orders coming in my database via api ... and wants to accept reject (change status of orders) via api , please guide


texts: Sidebar dropped out of column-Div, how can I put it back there via XML?

texts:
I have the normal sidebar on a blog page (we are using a module for creating blog structure in the backend), the layout of the page is layout="2columns-right".

The DOM is the following:

The desired DOM output is this:

How can I achieve this, by using XML and preferably the <move>-Term?

I have no idea why the sidebar drops out of its scope, every other CMS site is absolutely okay and there is no XML telling this specific page to render the Sidebar somewhere else...


texts: show massaction depending upon store configuration value

texts:
I have added one new mass action in sales order grid using UI component, I want to show mass action only if store configuration value set to yes.

If store configuration value set to No, then my custom mass action should not display.


texts:
Who can explain to me about data output in profiler report in csv format? I have the next data but don't know what is mean.

cache_frontend_create,0.023024,0.011512,2,"2,560,880",0
magento,8.667415,8.667415,1,"79,862,304","38,649,856"

magento->EVENT:core_collection_abstract_load_before,0.070687,0.070687,1,"273,448",0


texts: How to send mail in Magento 2 from custom Module?

texts:
I have created a custom module and in phtml file i have added html and by using ajax i will call the controller file.
But the issue is on using mail function it will show me an error on mail function parameter if i var dump the data it shows me bool(false).
I have configure Sendgrid to send mail and its test mail works so there is no problem with that all the test mail works fine so there will be an issue regarding the mail function with magento.
Is mail function didn't work in Magento 2 ?


texts:
I have created custom grid using UI component. My Full text searching showing error "Something went wrong with processing the default view and we have restored the filter to its original state.".

  Below is my code:

<filterSearch name="fulltext">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="component" xsi:type="string">Magento_Ui/js/grid/search/search</item>
                    <item name="displayarea" xsi:type="string">dataGridFilters</item>
                    <item name="provider" xsi:type="string">affiliate_newlisting_listing.affiliate_newlisting_listing_data_source</item>
                    <item name="chipsProvider" xsi:type="string">affiliate_newlisting_listing.affiliate_newlisting_listing.listing_top.listing_filters_chips</item>
                    <item name="storageConfig" xsi:type="array">
                        <item name="provider" xsi:type="string">affiliate_newlisting_listing.affiliate_newlisting_listing.listing_top.bookmarks</item>
                        <item name="namespace" xsi:type="string">current.search</item>
                    </item>
                </item>
            </argument>
        </filterSearch>

  what other things i have to do to make it working?

Thanks


texts: Fetch commission of related Designer for each ordered Product in admin Dashboard

texts:
We have lot of Designers in site (Seller/ Vendor). we assigned each product to one Designer.

we are displaying all the orders in custom page : www.1234.com/php/site6/orders.php

if we login as admin we can see all orders in page .

if we login as Designer1, than we can see all orders that contains Designer1's Products.

Now, Product 1 belongs to Designer1 [kidsdial2]

if any customer buy Product 1 than we will give commission to Designer1 & we need to display commission for designer in Orders.php page for that particular product in both admin & Designer Dashboard.

we are saving commission of each designer in tbl_users table

example: in above image , we assigned "10" as commission for Kidsdial2  Designer . so if any Kidsdial2's product bought by customer, than we need to display "10" as commission for that Ordered Product in both Designer & admin Dashboard.

Edit 2

in Designer account [kidsdial2] commission value is displaying correct value .but when i logged in with admin account [kidsdial1] , commission is displaying as "5" for  admin dashboard because for "kidsdial1" we are saving commission as 5 in Database. But as Product belongs to "Kidsdial2", it should display "10" instead of 5 in admin dashboard too.

Designer Dashboard

admin Dashboard

if($accountType == "admin")
{

$stmt = $user_home->runQuery("SELECT commission1 FROM tbl_users where userID=:uid");
$stmt->execute(array(":uid" => $_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$commission =  $row['commission1'] ;

$responce[] = array(
$commission
);
}

related code :

foreach($order as $orderData)
{
$k = 0;
$orderitems = $orderData['dproduct_id'];
$orderitemsarray = explode(",", $orderitems);

while ($k < count($orderitemsarray))
{

if ($orderitemsarray[$k] != '0')
{

$productdetail = Mage::getModel('catalog/product')->load($orderitemsarray[$k]);
$designer_id = $productdetail->getDesignerID() ;

if($accountType == "admin")
{

$stmt = $user_home->runQuery("SELECT commission1 FROM tbl_users where userID=:uid");
$stmt->execute(array(":uid" => $_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$commission =  $row['commission1'] ;

$responce[] = array(
$commission,
);
}

Edit 1  [ Ignore this part, Solved with help of Murtuza's answer ]

i need to display  commission value of Designer for that order [row] at last column.

$stmt = $user_home->runQuery("SELECT commission1 FROM tbl_users where userID=:uid");


texts: Magento change quantity shown for mobile only

texts:
I have this code here to show me a product collection. Currently shows me 12 on desktop and mobile. I would like to keep it at 12 on desktop. And only 5 on mobile devices.

Code is below and the part in question is $this->setProductsCount(12) ;

<?php
$_helper = $this->helper('catalog/output');
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
//$query = 'SELECT cid FROM tees_user_login_table where ((group_id = 1 and status = 1 and cid > 0) or (group_id in (2,3,4,5) and include_new = 1 and status = 1))';
$query = 'SELECT cid FROM tees_user_login_table where status = 1 and include_new = 1';
$results = $readConnection->fetchAll($query);
$categoryIds = array() ;
foreach($results as $k=>$v) {
    $categoryIds[] = $v['cid'] ;
}
$this->setProductsCount(12) ;
$this->getProductsCount() ;
$_productCollection = $this->getProductCollection()->setPageSize($this->getProductsCount())
    ->addAttributeToSelect(array('name','price','special_price','sku','small_image'))
    ->joinField('category_id',  // add category ID field to collection
        'catalog_category_product',
        'category_id',
        'product_id=entity_id',
        null,
        'left')
    ->groupByAttribute('sku')
    ->addAttributeToFilter('category_id', array('in' => $categoryIds));


texts: How to save cookies in magento 2 without disabling full page caching

texts:
I have created a plugin to for the layered naviagtion filters. Fore this I need to save the filter chosen in the cookies but the cookies are now saving. When I disable the full page caching, then everything works fine. Please help.

  Vendor/FilterPreference/Model/Layer/Filter/Attribute.php

<?php

namespace Vendor\FilterPreference\Model\Layer\Filter;

use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
use Magento\Framework\Stdlib\CookieManagerInterface;

/**
 * Layer attribute filter
 */
class Attribute extends \Magento\CatalogSearch\Model\Layer\Filter\Attribute {

    const COOKIE_NAME = 'appliedfilter';
    const COOKIE_DURATION = 86400; // One day (86400 seconds)

    /**
     * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory
     * @param \Magento\Store\Model\StoreManagerInterface $storeManager
     * @param \Magento\Catalog\Model\Layer $layer
     * @param \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder
     * @param \Magento\Framework\Filter\StripTags $tagFilter
     * @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
     * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
     * @param array $data
     */

    public function __construct(
    \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Model\Layer $layer, \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder, \Magento\Framework\Filter\StripTags $tagFilter, CookieManagerInterface $cookieManager, CookieMetadataFactory $cookieMetadataFactory, array $data = []
    ) {
        parent::__construct(
                $filterItemFactory, $storeManager, $layer, $itemDataBuilder, $tagFilter, $data
        );
        $this->_cookieManager = $cookieManager;
        $this->_cookieMetadataFactory = $cookieMetadataFactory;
    }

    /**
     * Apply attribute option filter to product collection
     *
     * @param \Magento\Framework\App\RequestInterface $request
     * @return $this
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function apply(\Magento\Framework\App\RequestInterface $request) {
        $attributeValue = $request->getParam($this->_requestVar);
        if (empty($attributeValue))
            $cookieValue = '';
        $cookieValue = $this->_cookieManager->getCookie(self::COOKIE_NAME);
        if ($cookieValue) {
            $param = explode('-', $cookieValue);
            if ($this->_requestVar == $param[0]) {
                $attributeValue = $param[1];
            }
        }
        if (empty($attributeValue) && !is_numeric($attributeValue)) {
            return $this;
        }
        $attribute = $this->getAttributeModel();
        /** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */
        $productCollection = $this->getLayer()
                ->getProductCollection();

        /* Set Cookie of Filter---Start */
        $cookieValue = $this->_cookieManager->getCookie(self::COOKIE_NAME);
        if (!$cookieValue || $cookieValue != $attribute->getAttributeCode() . '-' . $attributeValue) {
            $metadata = $this->_cookieMetadataFactory
                    ->createPublicCookieMetadata()
                    ->setDuration(self::COOKIE_DURATION);
            $this->_cookieManager
                    ->setPublicCookie(self::COOKIE_NAME, $attribute->getAttributeCode() . '-' . $attributeValue, $metadata);
        }
        /* Set Cookie of Filter---End */

        $productCollection->addFieldToFilter($attribute->getAttributeCode(), $attributeValue);
        $label = $this->getOptionText($attributeValue);
        $this->getLayer()
                ->getState()
                ->addFilter($this->_createItem($label, $attributeValue));

        $this->setItems([]); // set items to disable show filtering
        return $this;
    }

}


texts: My downloadable product page showing html source only

texts:
I have installed theme  http://themeforest.net/item/hosoren-responsive-magento-fashion-theme/12784020

It's working fine. But when I click on My Downloadable Products link from my account section, it showing html source.

URL: http://127.0.0.1/xyz.com/downloadable/customer/products showing page source only.

Can anybody help me to find solution please ?


texts: Getting error on custom add to cart Magento

texts:
I am trying to submit custom add to cart on product page with configurable product options but i am getting error with that.My code looks like this :

<script>
 jQuery("#submit").click(function () {
var color = jQuery('#colors').val();
var qty = jQuery('#qty').val();;
var size = jQuery('#sizes').val();;
alert(window.location.href = '<?php echo Mage::getBaseUrl(); ?>checkout/cart/add?product=<?php echo $current_product_id; ?>&qty='+ qty + '&super_attribute[139]='+ size +'&super_attribute[141]='+ color+'');
 window.location.href = '<?php echo Mage::getBaseUrl(); ?>checkout/cart/add?product=<?php echo $current_product_id; ?>&qty='+ qty + '&super_attribute[139]='+ size +'&super_attribute[141]='+ color+'';
});
</script>

where 139 and 141 are the attributes ids.I am getting the error Please specify the product's option(s).what i am doing wrong ?


texts: Configure Apache Solr 6.5.0 into Magento 2.1.3 Community Edition

texts:
How to configure Apache Solr 6.5.0 into Magento-2.1.3 Community Edition.

I have followed this official Documentation but it is only for Magento EE.

Please provide some documentation or steps where I can start implementation Solr Search to Magento 2 CE.


texts: Get html from two layout updates on ajax requet

texts:
I'm trying rerender onepage checkout billing and shipping steps on ajax request. I'm trying following code

        $layout = $this->getLayout();
        $update = $layout->getUpdate();
        $update->load('checkout_onepage_progress_shipping_method');
        $layout->generateXml();
        $layout->generateBlocks();
        $output = $layout->getOutput();
        $response['shipping'] = $output;

        $layout = $this->getLayout();
        $update = $layout->getUpdate();
        $update->load('checkout_onepage_paymentmethod');
        $layout->generateXml();
        $layout->generateBlocks();
        $output = $layout->getOutput();
        $response['payment'] = $output; // second output same as first one

But both outputs are same.
How can I get output from different updates?


texts: Magento 2: location for custom templates in custom theme

texts:
I have a question about how to organize a custom theme. I am planning to build a new theme that does not extend the blank theme. I am building my own blank theme so to speak.

I get the idea that modules template files reside in their respective folder inside my theme folder, e.g. Magento_Catalog/ and so on.

But my custom theme needs more template files that have no module to derive from. Where would I put those files?

Is Magento_Theme actually a custom theme's first point of entry?


texts:
How can I link products together?

Here's an example scenario.

Customer wants to buy carpet, which they can then choose to add underlay to. A Carpet is a configurable product, and Underlay is a Simple product

I have created an observer which listens to checkout_cart_add_product_complete, when this event is triggered, I check if they've selected to add underlay, if so, I programmatically add the product to the cart.

This all works fine, but the issue I'm having is when they view the shopping cart, there are two products in there. If the customer then adds a different Carpet with the same underlay, then there will be 3 products as the quantity will just be increased for the underlay.

Is there a way to link the products together at the point that they're added to the cart. So Carpet 1 and Underlay 1, is one product and Carpet 2 and Underlay 1 is another?

Hopefully this all makes sense.

Thanks in advance.


texts: Magento on Local Host won't show any image or CSS files?

texts:
I am running a copy of Magento on my localhost so that I can make changes without affecting the live site. I have imported a database which was backed up from the 'live' site and have changed the web/secure/base_url and web/unsecure/base_url to http://localhost/magento/ and I am able to see my database BUT I can't see any of the skins, image files etc. I know this is linked to the database because if I change the DB credentials in local.xml to a different database it loads everything perfectly. Problem though is that I need this database.

Any ideas?

I have also tried 'http://localhost:8888/magento/index.php/' to be more precise and see if that works, but it didn't. I've spent hours trying to get this up and running and am so close!


texts: Magento : Backend Model, Save Multiselect Attribute when condition is matched

texts:
I am trying to customize an extension (Customer Groups Catalog 2 = http://www.magentocommerce.com/magento-connect/customer-groups-catalog2.html),

It has a multiselect attribute (groupscatalog2_groups) of product in which admin can assign customer groups to product, and when i checked it in admin it doesn't have any option.

It has source, backend and frontend model assigned in addAttribute in mysql script.

Now, in backend model, it has beforeSave, afterSave and afterLoad method which handles saving and displaying that attribute options.

I want to set that attribute when a condition is matched in frontend, is it possible to do so ?

I tried $prdctModel->addData() method as we generally do for multiselect attribute, but it's not working.

Any Suggestions ?


texts: Changing Tax before or after Discount depending on Coupon Code

texts:
I really hope, that somebody will have an answer/idea how to solve this!
Depending on the Coupon Code the customer is entering during checkout I need to change the tax calculation from "before discount" to "after discount" and visa versa.
I have an own modul where I could change the value in the database right after the coupon code is entered, but this does not effect the tax calculation because the value for this seems to be red only once at the beginning of the checkout.
I found the class where the tax is calculated, it is AbstractAggregateCalculator in the tax Modul. But in this class there is no referenz to the quote where the coupon Code is stored and getting it with methods f.e. via objectManager is throwing afterwards an "inifinite loop detection...." and order cannot be placed. As well an own override seems not to work because of protected functions.
The Value which is responsible in this class for the tax calculation is:
$applyTaxAfterDiscount = $this->config->applyTaxAfterDiscount($this->storeId);
So, it is somewhere stored in $this->config. I think is is as well js storage.
Therefore my question is how to change/set this value within an own modul/plugin or any idea way to do this.
By the way, I am working currently with Magento Version 2.3.5
Hopfefully somebody does have an idea.
Looking forward to hearing from you soon.
Best regards
Chequille


texts: Product image files being added more than once (_1, _2, _3, etc.)

texts:
So this is odd. I've noticed this since 2.3.x (I'm now on 2.4.1) but it is getting annoying and I'm wondering if anyone knows why it does this (and hopefully a fix? Or how to stop it from doing this).
While creating a product and adding an image to the 'Color - Red' variation, the same exact image (original filename: Product_Red_Front.jpg)  gets duplicated as

Product_Red_Front_1.jpg (12.81kb)
Product_Red_Front_2.jpg (12.81kb)
Product_Red_Front_3.jpg (12.81kb)
Product_Red_Front_4.jpg (12.81kb)
Product_Red_Front_5.jpg (12.81kb)

My guess it's for each product 'size', because if I have S-XXL sizes that's 5 sizes = 5 files made. I'm only selecting "Apply unique images by attribute to each SKU" and selecting "Color".
But that turns a set of ~35kb images on my server into ~200kb. For_no_reason. Just takes up space for no reason. And makes it a headache to manage (say if I want to optimize the files in the future, I would have to optimize 5 files (and rename them as such) for each product side for every...color...)
I've added a picture for an example. For 1 color, 3 sides (so it 'should' be 3 files only per color) it created 15 files. From 35kb to 200kb. Just makes no sense, hopefully someone will know why it is doing this? Imagine having 4 or 5 sides...ugh. 30+ images for one color...lol
Just to prove this is pointless, I could export the products (as csv), change the image it uses to simply red_front.jpg, red_side.jpg, red_back.jpg for each product and it would work fine. (but obviously I'm not trying to do this, waste time, as it shouldn't be doing this to begin with - it's not like it's resizing the images or anything special, just duplicating them)
I saw this topic: Strange Issue product image filename adding _1 to the filename but the answer didn't work for me, I didn't have anything in the 'tmp' folder :/
Thank you for your time, it is much appreciated.


texts: I Need to Collect the Product Randomly, with store id

texts: I want to show the Product with randomly on particular site from Multistore and Status is enabled, Stock is Instock and Select the All attributes from these collection of Product In Magento Home Page


texts: Temporary price drop when item added to cart

texts: Was at Amazon today and noticed when I added an item to my cart, it immediately took like 10% off of my order total but said the 10% offer was only good for so many minutes and then the offer would end. Does anybody know of a Magento module that does this? Would be nice to also run it after hours to encourage more sales.


texts: How can I check if an image is already set against a product?

texts:
I am doing a product import routine and have images added to my product. The problem I have is that magento creates a dispretion path and then add's some numbers onto the end of my image file name to ensure it's not a duplicate. I need to find a way to check if myimage.jpg has been added to a product or not.

I can find the dispretion path using Mage_Core_Model_File_Uploader::getDispretionPath($fileName); so that isn't a problem but from what I can see there isn't a way to map the file name I uploaded to the one magento renamed it do, for instance:

I add an image called BadgersSmall.jpg and this is what magento returns as part of the MediaGallery collection

[value_id] => 5
[file] => /B/a/BadgersSmall_6_1.jpg
[label] =>
[position] => 2
[disabled] => 0
[label_default] =>
[position_default] => 2
[disabled_default] => 0
[url] => http://www.localhost.com:8080/magento/media/catalog/product/B/a/BadgersSmall_6_1.jpg
[id] => 5
[path] => C:\xampp\htdocs\magento\media\catalog\product\B\a\BadgersSmall_6_1.jpg

The only thing I can think of at this point is running _getNotDuplicatedFilename($fileName, $dispretionPath); on my current image and then checking the index at the end of the file, subtract 1 and that "should" be the previous file I uploaded but this solution is simply horrible.

EDIT
My new plan is to create a database table that will hold my product code, file name and the file name magento creates. I will insert this when I add new images. I will also need to add something in to observe the delete image event so I can remove the entry as well.

Any ideas?


texts: what RP means in Url Rewrite Management options column

texts: I look at the Url Rewrite Management for custom URL rewrite and found that there are RP in option column. What is the difference between RP and non RP custom option?


texts: Remove "add new customer" button in ui component grid with condition base?

texts:
I want to remove the "add new customer" button in condition base.
"add new customer" button only display for main admin, not any child admin.

any have an idea about the same problem.
Thank you in advance


texts: One Page Checkout - Manually setAddress()

texts:
In One Page Checkout, the Billing class offers a setAddress(val) function that looks useful for setting the address that gets chosen when a user that has saved addresses selects one from the first-step of the checkout process.

When you call, say, setAddress(2) it will populate the hidden form with the proper values for that address. I am doing some custom validation on this form, so I appreciate being able to update the hidden form. I am doing a simple call:

jQuery('#billing-address-select').change(function(){
    option = jQuery('#billing-address-select option:selected').val();
    billing.setAddress(option);
});

However, after a user changes the selected address, after a quick Ajax call, the selected option gets automatically reverted back to the 'New Address' option (which has a null value).

The only thing I can see where this would happen, there is onchange="billing.newAddress(!this.value)" set on the select element. Looking at this method, though, all it is doing is showing or hiding the hidden form as needed.

Why is this form element getting reverted back to the 'New Address' option?


texts:
After looking at various methods, the following code is almost getting what I want:

 $product = Mage::getModel('catalog/product')->load($product_id);
 $site_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
 $product_url = '';
 $cats = $product->getCategoryIds();
 if (sizeof($cats)) {
     $category = Mage::getModel('catalog/category')->load((int) $cats[0]);
     $product_url = $site_url.$product->getUrlPath($category);
 }

This returns: http://magento.dev/men/shirts/french-cuff-cotton-twill-oxford-570.html.

However this produces a 404.

570 is not the ID that corresponds to this product so I'm wondering where it's coming from.


texts: Add a block to a page with event observer

texts:
I'm trying to add a static block to a page with an observer.
The event that I'm listening to is controller_action_layout_generate_blocks_after and this is my observer code:

<?php
...
class Antonino_Banner_Model_Observer
{
    public function showBannerWhenLoad(Varien_Event_Observer $observer)
    {
        $layout = Mage::app()->getLayout();
        $pageId = Mage::app()->getRequest()->getParam('id');
        $selectedCatId = Mage::getStoreConfig('antoninobanner/general/choose_category');

       if ($pageId==$selectedCatId){
           Mage::log('Bingo! PageId= '. $pageId.' SelectedId= '.$selectedCatId);
           $messageBlock = $layout->createBlock('cms/block')->setBlockId('antonino_banner');
           $breadcrumbs = $layout->getBlock('breadcrumbs');
           $breadcrumbs->append($messageBlock);
       }/*else{
           Mage::log('Oh no! The ids do not match');
       }*/
    }
}

The event is regularly triggered and in the system.log I can read the "Bingo!..." string.
But on the page, the 'antonino_banner' block is not added.
Naturally, I've created a static block in admin->static blocks.

Any help will be appreciated,
thanks.


texts:
I have updated the magento cloud EE version from 2.2.0 to latest but on local it works fine when i push my code to cloud then it gives me errors

i tried following command:

  composer require "magento/magento-cloud-metapackage":">=2.3.2 <2.3.3" --no-update

then,

update composer and update php version in app.magento.yaml

then add composer.json && composer.lock && .app.magento.yaml
and commit the code and then push

after running command it gives me following errors

CRITICAL: The command "php ./bin/magento module:enable --all --ansi --no-interaction" failed. PHP Fatal error:  Cannot redeclare __() (previously declared in /app/vendor/magento/framework/Phrase/__.php:15) in /app/app/functions.php on line 22
        W:
        W: In RefreshModules.php line 55:
        W:
        W:   The command "php ./bin/magento module:enable --all --ansi --no-interaction"
        W:    failed. PHP Fatal error:  Cannot redeclare __() (previously declared in /a
        W:   pp/vendor/magento/framework/Phrase/__.php:15) in /app/app/functions.php on
        W:   line 22
        W:
        W:
        W: In Shell.php line 86:
        W:
        W:   The command "php ./bin/magento module:enable --all --ansi --no-interaction"
        W:    failed. PHP Fatal error:  Cannot redeclare __() (previously declared in /a
        W:   pp/vendor/magento/framework/Phrase/__.php:15) in /app/app/functions.php on
        W:   line 22
        W:
        W:
        W: build
        W:

      E: Error building project: Step failed with status code 255.

Please guide me as if i am running wrong commands or in solving above issues

Thanks in advance.


texts:
<layout>
  <navContainerName>left</navContainerName>
  <type>tabs</type>
</layout>

I have used the tab in form.xml but data not being populated within form while edit.


texts:
I am working with magento soap api and it's works fine in my local machine and development server but when i moved my code to production server i found the following error:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.mydomain.com/magento/index.php/api/soap/index/?wsdl=1' : failed to load external entity "http://www.mydomain.com/magento/index.php/api/soap/index/?wsdl=1" Stack trace: #0 [internal function]: SoapClient->__call('login', Array) #1

I have also check the SOAP setting on server everything is OK but still this error comes.


texts: Controller not executing if changing constructor parameters

texts:
I have a Controller class as follow :

    class Delete extends \Magento\Framework\App\Action\Action
{

   protected $cache;
   protected $cacheManager;

   public function __construct(
    \Magento\Framework\App\Action\Context $context,
    \Magento\Framework\App\Cache\TypeListInterface $cache,
    \Magento\Framework\App\Cache\Manager $cacheManager
)
   {
     parent::__construct($context);

     $this->cache = $cache;
     $this->cacheManager = $cacheManager;
 }

 public function execute()
 {

    $value = $this->getRequest()->getParam('post_id');
    $this->_resources = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\App\ResourceConnection');
    $connection= $this->_resources->getConnection();

    $themeTable = $this->_resources->getTableName('thienphucvx_sample');
    $sql = "DELETE FROM $themeTable WHERE post_id=$value";
    $connection->query($sql);

}
}

This controller is intended to delete a data from DB, what is strange is that when I simply add cache and cacheManager in the constructor, I have an ajax response from the controller but the delete is not processing. When I delete those 2 parameters from the constructor, all is well executing. What's going wrong with this constructor ?


texts: Checkout form custom address attribute input renderer "Object Object"

texts:
I have follow https://devdocs.magento.com/guides/v2.3/howdoi/checkout/checkout_new_field.html
and I have this result for my custom address attribute ( this attribute is save in customer account page )
https://gyazo.com/07ab49785c13e1ea106d742396594a35
If I update this field in checkout form, the result is correct ( correct value is showing on input )
Thanks


texts: Magento-2 Validate input field without form

texts:
How to validate email input field without form? I have tried with below code but not working.

<input class="input-text"
       type="email"
       data-validate="{required:true, 'validate-email':true}"
       id="email"
       type="text"
       placeholder="Enter email address" name="email"/>