## abstract algebra – Associativity of cup product in Homology

Studying Algebraic Topology from Tom Dieck I came across cup product. I was trying to verify whether there were a way to prove associativity without using the direct formula of cup, just exploit the naturality of cap product thanks to its definition on chain level (depending on Eilenberg-Zilber Theorem for example using the Alexander-Whitney map).

In particular in my notes there’s the following diagram, but I don’t know what should suggest me

$$begin{array}{ccccccccc} X & overset{triangle}{rightarrow} & X times X & overset{1 times triangle}{rightarrow} X times(X times X) \ & & downarrow{triangle times 1} & \ & & (X times X) times X end{array}$$

Where $$triangle$$ is the diagonal map and $$1$$ is the identity.

Any help or answer would be appreciated.

## Configurable product duplicates smaller images (below the main image)

I’ve seen all the videos on how to configure a configurable product. And I can’t find the error.

See the image please.

## ajax – Product doesn’t get added to cart on mobile

ajax – Product doesn’t get added to cart on mobile – WordPress Development Stack Exchange

## matrices – In matrix product, differentiate one element with respect to another element

I have three matrices $$A,B,C$$ and I know that $$AB=C$$
In my case, any of these might be singular.

Is it possible to derive an expression for the derivative of one element of $$B$$ w.r.t. an (arbitrary) element of $$A$$? i.e.

$$frac{partial B_{ij}} {partial A_{kl}}$$

Thanks!

## Check if product is backorder

I need to check if items in success page are backorder or not.
I need your help

## 8 – How to add conditions to display product variations in Drupal commerce?

In the products page, I want to limit product variations based on user roles.
For example, I only want admin to be able to see some of the product variation.
I tried to achieve this by adding an extra field in variation and then checking that field in twig template (commerce-product.html.twig). Unfortunately, this method only works with rendered entity and I couldn’t use the “add to cart” functionality.
Is there a way to run a condition before displaying a product variation (along with the add to cart form)?

## magento2.3 – Magento 2.3.5-p1 How to add a prefix to the product url?

I am working on Magento 2.3.5-p1 and I need to add a prefix in the product urls just before the product name.

I have tried with this example but there is a deprecated function so it fails. So I have copied the original files from my Magento 2.3.5-p1 and modified some parts according to the example, but it still doesn’t work. I leave my code below in case someone can help me.

Vendor/Module/Model/Url.php

``````<?php
declare(strict_types=1);

namespace VendorModuleModel;

use MagentoUrlRewriteModelUrlFinderInterface;
use MagentoUrlRewriteServiceV1DataUrlRewrite;
use MagentoFrameworkAppConfigScopeConfigInterface;

class Url extends MagentoCatalogModelProductUrl
{
/**
* URL instance
*
* @var MagentoFrameworkUrlFactory
*/
protected \$urlFactory;

/**
* @var MagentoFrameworkFilterFilterManager
*/
protected \$filter;

/**
* Store manager
*
* @var MagentoStoreModelStoreManagerInterface
*/
protected \$storeManager;

/**
* @var MagentoFrameworkSessionSidResolverInterface
*/
protected \$sidResolver;

/** @var UrlFinderInterface */
protected \$urlFinder;

/**
* @var MagentoFrameworkAppConfigScopeConfigInterface
*/
private \$scopeConfig;

/**
* @param MagentoFrameworkUrlFactory \$urlFactory
* @param MagentoStoreModelStoreManagerInterface \$storeManager
* @param MagentoFrameworkFilterFilterManager \$filter
* @param MagentoFrameworkSessionSidResolverInterface \$sidResolver
* @param UrlFinderInterface \$urlFinder
* @param array \$data
* @param ScopeConfigInterface|null \$scopeConfig
*/
public function __construct(
MagentoFrameworkUrlFactory \$urlFactory,
MagentoStoreModelStoreManagerInterface \$storeManager,
MagentoFrameworkFilterFilterManager \$filter,
MagentoFrameworkSessionSidResolverInterface \$sidResolver,
UrlFinderInterface \$urlFinder,
array \$data = (),
ScopeConfigInterface \$scopeConfig = null
) {
parent::__construct(\$urlFactory, \$storeManager, \$filter, \$sidResolver, \$urlFinder, \$data);
\$this->urlFactory = \$urlFactory;
\$this->storeManager = \$storeManager;
\$this->filter = \$filter;
\$this->sidResolver = \$sidResolver;
\$this->urlFinder = \$urlFinder;
\$this->scopeConfig = \$scopeConfig ?:
MagentoFrameworkAppObjectManager::getInstance()->get(ScopeConfigInterface::class);
}

/**
* Retrieve URL in current store
*
* @param MagentoCatalogModelProduct \$product
* @param array \$params the URL route params
* @return string
*/
public function getUrlInStore(MagentoCatalogModelProduct \$product, \$params = ())
{
\$params('_scope_to_url') = true;
return \$this->getUrl(\$product, \$params);
}

/**
* Retrieve Product URL
*
* @param  MagentoCatalogModelProduct \$product
* @param  bool \$useSid forced SID mode
* @return string
*/
public function getProductUrl(\$product, \$useSid = null)
{
\$params = ();
if (!\$useSid) {
\$params('_nosid') = true;
}
return \$this->getUrl(\$product, \$params);
}

/**
* Format Key for URL
*
* @param string \$str
* @return string
*/
public function formatUrlKey(\$str)
{
return \$this->filter->translitUrl(\$str);
}

/**
* Retrieve Product URL using UrlDataObject
*
* @param MagentoCatalogModelProduct \$product
* @param array \$params
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function getUrl(MagentoCatalogModelProduct \$product, \$params = ())
{
\$routePath = '';
\$routeParams = \$params;

\$storeId = \$product->getStoreId();

\$categoryId = null;

if (!isset(\$params('_ignore_category')) && \$product->getCategoryId() && !\$product->getDoNotUseCategoryId()) {
\$categoryId = \$product->getCategoryId();
}

if (\$product->hasUrlDataObject()) {
\$requestPath = \$product->getUrlDataObject()->getUrlRewrite();
\$routeParams('_scope') = \$product->getUrlDataObject()->getStoreId();
} else {
\$requestPath = \$product->getRequestPath();
if (empty(\$requestPath) && \$requestPath !== false) {
\$filterData = (
UrlRewrite::ENTITY_ID => \$product->getId(),
UrlRewrite::ENTITY_TYPE => MagentoCatalogUrlRewriteModelProductUrlRewriteGenerator::ENTITY_TYPE,
UrlRewrite::STORE_ID => \$storeId,
);
\$useCategories = \$this->scopeConfig->getValue(
MagentoCatalogHelperProduct::XML_PATH_PRODUCT_URL_USE_CATEGORY,
MagentoStoreModelScopeInterface::SCOPE_STORE
);

\$filterData(UrlRewrite::METADATA)('category_id')
= \$categoryId && \$useCategories ? \$categoryId : '';

\$rewrite = \$this->urlFinder->findOneByData(\$filterData);

if (\$rewrite) {
\$requestPath = \$rewrite->getRequestPath();
\$product->setRequestPath(\$requestPath);
} else {
\$product->setRequestPath(false);
}
}
}

if (isset(\$routeParams('_scope'))) {
\$storeId = \$this->storeManager->getStore(\$routeParams('_scope'))->getId();
}

if (\$storeId != \$this->storeManager->getStore()->getId()) {
\$routeParams('_scope_to_url') = true;
}

if (!empty(\$requestPath)) {
\$routeParams('_direct') = \$requestPath;
} else {
\$routePath = 'catalog/product/view';
\$routeParams('id') = \$product->getId();
\$routeParams('s') = \$product->getUrlKey();
if (\$categoryId) {
\$routeParams('category') = \$categoryId;
}
}

// reset cached URL instance GET query params
if (!isset(\$routeParams('_query'))) {
\$routeParams('_query') = ();
}

/*\$url = \$this->urlFactory->create()->setScope(\$storeId);
return \$url->getUrl(\$routePath, \$routeParams);*/

\$baseUrl = \$this->storeManager->getStore()->getBaseUrl();
\$productUrl = \$this->getUrlInstance()->setScope(\$storeId)->getUrl(\$routePath, \$routeParams);

\$remainingUrl = str_replace(\$baseUrl, '', \$productUrl);

\$productUrl = \$baseUrl."product/" . \$remainingUrl;
//return \$this->getUrlInstance()->setScope(\$storeId)->getUrl(\$routePath, \$routeParams);
return \$productUrl;
}
}
``````

Vendor/Module/Controller/Router.php

``````<?php
namespace VendorModuleController;
use MagentoUrlRewriteModelUrlFinderInterface;
use MagentoUrlRewriteServiceV1DataUrlRewrite;
class Router implements MagentoFrameworkAppRouterInterface
{
protected \$actionFactory;
protected \$storeManager;
protected \$urlFinder;
public function __construct(
MagentoFrameworkAppActionFactory \$actionFactory,
MagentoStoreModelStoreManagerInterface \$storeManager,
UrlFinderInterface \$urlFinder
) {
\$this->actionFactory = \$actionFactory;
\$this->storeManager = \$storeManager;
\$this->urlFinder = \$urlFinder;
}
public function match(MagentoFrameworkAppRequestInterface \$request)
{
\$replaceUrl = str_replace("product/", "", \$request->getPathInfo());
\$rewrite = \$this->getRewrite(\$replaceUrl, \$this->storeManager->getStore()->getId());
if (\$rewrite == null)
{
return null;
}
\$request->setAlias(MagentoFrameworkUrlInterface::REWRITE_REQUEST_PATH_ALIAS, \$rewrite->getRequestPath());
\$request->setPathInfo("https://magento.stackexchange.com/" . \$rewrite->getTargetPath());
return \$this->actionFactory->create('MagentoFrameworkAppActionForward');
}
protected function getRewrite(\$requestPath, \$storeId)
{
return \$this->urlFinder->findOneByData((
UrlRewrite::REQUEST_PATH => trim(\$requestPath, "https://magento.stackexchange.com/"),
UrlRewrite::STORE_ID => \$storeId,
));
}
}
``````

Thanks in advance.

## commerce – Product Attributes that do not require product variations

I am trying to figure out if it is possible to have product attributes that do not require individual SKUs and do not have to be entered as product variations. My use case is this: We are selling dinners with three different entrees and three different desserts. We do not need to charge different amounts for each combination, but we do need to know how many of each have been ordered. I can make this work by creating a separate product variation for each combination, but is there an easier way??

I have looked at commmerce_pricing_attributes and commerce_option but the project pages for these modules say that they only work with D7.

I am running commerce 8.x-2.24 on version 9.2.4 of Drupal

## linear algebra – Performing matrix tensor product and getting a sum of its negative entries

If it is only about the sums of negative entries, then yes.

This is how we can do it without even building the tensor/Kronecker products:

``````M = RandomReal({-1, 1}, {3, 3});
ClearAll(sumPositive);
ClearAll(sumNegative);
sumPositive(1) = Total(Ramp(M), 2);
sumNegative(1) = Total(Ramp(-M), 2);
sumNegative(n_) := sumNegative(n) = Plus(
sumPositive(n - 1) sumNegative(1),
sumNegative(n - 1) sumPositive(1)
);
sumPositive(n_) := sumPositive(n) = Plus(
sumPositive(n - 1) sumPositive(1),
sumNegative(n - 1) sumNegative(1)
);
``````

Test for `n = 8`:

``````n = 8;
result1 = sumNegative(n); // MaxMemoryUsed // AbsoluteTiming
result2 = Total(Ramp(-KroneckerProduct @@ ConstantArray(M, n)), 2); // MaxMemoryUsed // AbsoluteTiming

result1 == result2
``````

{0.00007, 4080}

{1.63739, 688748008}

True

Notice that `sumNegative(n)` needs $$O(n)$$ memory and FLOPs while the brute force approach needs $$O(9^n)$$ of both.

The key idea that the sum of all entries of a tensor product is just product of the sums:

``````Total(KroneckerProduct(A, A), 2) == Total(A, 2)^2
``````

Now we only have onlt to keep track of the negative and the nonnegative parts of the tensors… Combined with recursion and memoization, we are lead to `sumPositive` and `sumNegative`.

## How to add DatePicker in Product Image Details at admin in magento 2

At product edit page, I’m trying to add image hide date “a custom field of datepicker” so far it shows the inputbox but not calender upon clicking the box. I have override gallery.phtml and added custom input, but the script code for calender is not working.

Here’s the code:

``````<div class="admin__field field-display-image">
<div class="admin__field-control">
<div class="admin__field admin__field-option">
<label for="display-image-from-product-page-<%- data.file_id %>" class="admin__field-label vashi">
<?= /* @escapeNotVerified */ __('Image Time Scope') ?>
</label>
<input type="text" class="input-text" id="example-date" style="width: auto" name="example-date" />
</div>
</div>
</div>
``````

and script

``````<script>
require((
'jquery',
'mage/translate',
'mage/calendar'
), function (\$, \$t) {
\$('#example-date').calendar({
alert('hi');
changeMonth: true,
changeYear: true,
showButtonPanel: true,
currentText: \$t('Go Today'),
closeText: \$t('Close'),
showWeek: true
});
})
</script>
``````

All these in gallery.phtml